Why react uses setState twice in a function (the second time in settimeou) why it still merges execution.

I want to do one to prevent repeated clicks, but now isClickable can"t be set to false, to comment out settimeout. Of course, after adding normal disable, disable becomes invalid. -sharp-sharp-sharp problem description

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

handleButtonClickTest = (hireTeamId) = > {

this.props.actions.deleteHiringTeamMember(hireTeamId);
this.setState({
  isClickable: false,
});
setTimeout(this.setState({ isClickable: true }), 5000);

}

what result do you expect? What is the error message actually seen?

Dec.01,2021

setTimeout should be written

  

I suggest that this variable be global. You don't have to put state, because setState is an asynchronous function, so you can assign a value directly if it is global.

Menu