I am updating a state from child.
getInitialState : function(){
return{
VotedForTopic : false
};
},
updateVotedState:function(){
this.setState({VotedForTopic:true});
console.log(this.state.VotedForTopic)
},
I am calling updateVotedState from the child when some action is performed to change the VotedForTopic state to true.But the state is not getting updated it remains false. What could be the problem
this.setState(newState)
is async. it happens very fast, but you can move theconsole.log
into your render method and you'll see it update.