⊗jsrtPmFcEO 35 of 112 menu

The Event Object in React

Inside the function bound to the event handler, the object Event is available:

function App() { function func(event) { console.log(event); // object with event } return <div> <button onClick={func}>act</button> </div>; }

The event variable does not receive the native Event browser object, but a special cross-browser wrapper over it from React. This wrapper is called SyntheticEvent. This wrapper helps events work the same way in all browsers. It has the same interface as the native event, including the stopPropagation and preventDefault methods.

A button is given. By clicking on it you will get the object Event and output it to the console.

A button is given. By clicking on it you will receive output to the console event.target click.

enru