Here is a summary of the code I have inside my React component:
getInitialState: function(){
return{link:\"\"}
},
onClick1: function(){
this.setState({
From the docs:
setState()
does not immediately mutatethis.state
but creates a pending state transition. Accessingthis.state
after calling this method can potentially return the existing value.There is no guarantee of synchronous operation of calls to
setState
and calls may be batched for performance gains.
If you want a function to execute after the state transition completes, pass it in as a callback:
onClick1: function() {
this.setState({link:"Link1"}, this.otherFunction);
},