What is the recommended/cleanest way to dynamically change an event's binding in react?
For example, if I initially have a button like this
<button type="button" onClick={this.handleFirstClick}>
Then in the handleFirstClick method
handleFirstClick() {
//do other stuff
//rebind the button, so that next time it's clicked, handleSecondClick() would be called
}
In case it's not entirely clear what I mean, here's what I'd like to do, using jQuery instead of React
$('#myButton').on('click', handleFirstClick);
function handleFirstClick() {
//other stuff
$('#myButton').off('click');
$('#myButton').on('click', handleSecondClick);
}
handleClick()call the proper functions accordingly.