Scopes in Event Handlers
Learn how to bind class methods to the instance using different binding methods.
Scoping
Usually, the use of ES2015 classes in React mandates that event handlers have to be defined as methods of the current class component. However, class methods are not automatically bound to the instance. Let’s unpack what this means. Initially, this
will be undefined
in all of our event handlers.
Here is an example to reiterate this:
Get hands-on with 1400+ tech skills courses.