ReactJS - Need to click twice to set State and run function

前端 未结 3 1617
长发绾君心
长发绾君心 2021-01-02 06:40

Here is a summary of the code I have inside my React component:

getInitialState: function(){
  return{link:\"\"}
},
onClick1: function(){
   this.setState({         


        
3条回答
  •  一生所求
    2021-01-02 07:20

    If all that onClick does is change the state, then you shouldn't have two functions that do the same job. You should have the new value of the "link" state passed as an argument to the function "onClick" :)

提交回复
热议问题