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 much
// happening here other than a log of the event.
onClick() {
console.log('clicked');
}
// Renders a "<button>" element with the "onClick"
// event handler set to the "onClick()" method of
// this component.
render() {
return (
<button onClick={this.onClick}>{this.props.children}</button>
);
}
}
The event handler function, this.onClick(), is passed to the onClick property of the <button> element. By looking at this markup, it's clear what code is going to run when the button is clicked.
See the official React documentation for the full list of supported event property names: https://facebook.github.io/react/docs/.