How to call multiple functions on the same onClick event ReactJS

后端 未结 3 936
予麋鹿
予麋鹿 2020-12-14 23:57

I have this function and when I click on the

  • tag, I want to call two functions, onClick={handleProjectSelection(project)} a handler func
  • 3条回答
    •  失恋的感觉
      2020-12-15 00:38

      You can do it in two ways:
      1.

      onClick={()=>{
          callFunctionOne();
          callFunctionTwo();
      }}
      

      2.

      callTwoFunctions(){
          callFunctionOne();
          callFunctionTwo();
      }
      
      onClick={this.callTwoFunctions}
      

    提交回复
    热议问题