Suppose that your component is actually a form with many input elements with many event handlers.
Binding each method in the constructor is both error-prone & very tedious.
Wow! This is awesome, Sung! My boot camp will be starting to learn React soon, which we're all excited about, so I'm even more excited now to know that I'll get to know arrow functions more intimately :)
I love 🏹 functions.
If you happen to learn React, you'd use arrow functions heavily
because
many components you build would require you to use ES6 "class" (until next release v16.7 alleviate the pain using what's called React Hooks).
In react, each Component (extending
React.Component
) has an access tosetState
method to update internal state.If you don't use an arrow function, methods can't access Component's
this.setState
thus need to bindthis
in the constructor.Suppose that your component is actually a form with many input elements with many event handlers.
Binding each method in the constructor is both error-prone & very tedious.
Wow! This is awesome, Sung! My boot camp will be starting to learn React soon, which we're all excited about, so I'm even more excited now to know that I'll get to know arrow functions more intimately :)
Woohoo 😸.
Perfect time to learn about the arrow function as it will come in very handy for React ⚛.
And please disregard React Hooks initially, as it'd confuse you if you are just getting started with React