I am learning React an encountered two different ways of writing event handling functions and do not know if they are somehow semantical identically or if it is just different sytax?
This seems more intuitive for me:
clickHandler = () => {
this.setState({
random: Math.random(),
});
};
But in the book I am using they always do something like this:
clickHandler2() {
return () => {
this.setState({
random: Math.random(),
});
};
}
I created a CodePen and all the behavior seems the same, especially this binding. Is it just different syntax for the complete same behavior?