Event handler context and parameters

In this section, we'll examine React components that automatically bind their event handler contexts and how you can pass data into event handlers. Having the right context is important for React event handler functions, because they usually need access to properties or state of the component. Being able to parameterize event handlers is also important, because they don't pull data out of DOM elements.

Auto-binding context

The components you've implemented so far in this book have used the ES2015 class style declaration. This is where you declare a class that extends the base React Component class. When you do this, however, any event handler methods in the component will need to be manually bound to the component ...

Get React and React Native now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.