Declaring event handlers
The differentiating factor with event handling in React components is that it's declarative. Contrast this with something like jQuery, where you have to write imperative code that selects the relevant DOM elements and attaches event handler functions to them.
The advantage with the declarative approach of event handlers in JSX markup is that they're part of the UI structure. Not having to track down code that assigns event handlers is mentally liberating.
In this section, we'll write a basic event handler, so you can get a feel for the declarative event handling syntax found in React applications. Then, we'll look at using generic event handler functions.
Declaring handler functions
Let's take a look at a basic component that declares an event handler for the click event of an element:
import React, { Component } from 'react'; export default class MyButton extends Component { // The click event handler, there's nothing...