Handling Events
Learn to implement logic when users interact with components using events.
We'll cover the following...
JavaScript events are invoked when a user interacts with a web app. For example, when a user clicks a button, a click event will be raised from that button. We can implement a JavaScript function to execute some logic when the event is raised. This function is often referred to as an event listener.
Note: In JavaScript, event listeners are attached to an element using its
addEventListener
method and removed using itsremoveEventListener
method.
React allows us to declaratively attach events in JSX using function props, without the need to use addEventListener
and remove EventListener
. In this section, we are going to ...