简体   繁体   中英

Is there is any difference between Javascript events and React Events?

In javascript, we use onclick event and in React we use the onClick event. My question is event provides my React is the same as a javascript event or React handle event differently.

React uses a synthetic event system, which is a cross-browser wrapper around the browser's native event. In most cases, a developer may not notice the differences, but they do exist:

  1. React synthetic events work identically across browsers.
  2. React event handlers cannot return false to prevent the default behavior.
  3. React synthetic events always bubble.
  4. Before React 17, React synthetic events cannot be used in an asynchronous way unless e.persist() is called.
  5. React's synthetic event system for videos works the same way as HTML/JavaScript Events.

onclick and onClick events are the same.

The only difference is the capital of the "C".

Warning

onclick event is deprecated in javascript. Now, we use addEventListener and then onclick event inside.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM