1

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.

2 Answers 2

2

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.
Sign up to request clarification or add additional context in comments.

Comments

-1

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.

1 Comment

onclick is not depricated - it's perfectly fine to use it on your own element where only one event listener needs to be registered. if you build some tool/package then you should use addEventListener

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.