React events
React events
React has the same events as HTML: click, change, mouseover etc.
Adding Events
HTML:
Example:
function Football() {
alert("Great Shot!");
return (
);
root.render(<Football />);
Run Example »
Passing Arguments
To pass an argument to an event handler, use an arrow function.
Example:
function Football() {
alert(a);
return (
);
root.render(<Football />);
Run Example »
Event handlers have access to the React event that triggered the function.
Example:
function Football() {
alert(b.type);
/*
*/
}
return (
);
root.render(<Football />);
Run Example »