0

I am trying to create unique ID (i cannot use any Unique ID library, i can only use math.random function) for the weight object in the constructor and then pass it in the render method.


    constructor(props){

        super(props);

        const localDB = loadState();

        this.state = {

            username: localDB.account,
            PrivateKey: localDB.key,
            author: this.props.author,
            permlink: this.props.permlink,
            expanded: false,
            weight : this.props.weight

        };

        return (  
            <div className="upvote">

                <div id="upVote"><br /><input id="expandVote" type="button" value="Open voting UI" onClick={() => this.expandDropdown()} /></div>  
                { this.state.expanded ? <input id="this.state.weight" defaultValue="10" /> : null } 
                { this.state.expanded ? <button id="pushVote" onClick={() => this.pushVote()}>Push vote</button> : null } 
                { this.state.expanded ? <button id="closeVote" onClick={this.closeDropdown}>Close voting UI</button> : null }                       

            </div>
        )
    }
Nick2597
  • 21
  • 6
  • 1
    what is the question exactly? Where are you creating the id? What difficulties are you getting? – Gonzalo.- Apr 09 '19 at 21:21
  • I am working on a blockchain project where I have to differentiate weight value to each upvote by a unique ID. So my difficulty was creating a unique ID using math. random function in the constructor. Then i have to pass that string using the render method. – Nick2597 Apr 09 '19 at 22:26

0 Answers0