Event Handling is used to perform actions when a user interacts with the UI.

  • Button click
  • Mouse hover
  • Keyboard typing
  • Form submit
  • Input change
     
  1. onClick()
  2. onChange()
  3. onSubmit()
  4. onMouseOver()
  5. onKeyDown()
  6. onDoubleClick()
function App() {
 function showMessage() {
   alert("Button Clicked");
 }
 return (
   <button onClick={showMessage}>
     Click Me
   </button>
 );
}
export default App;

What is Event Handling in React?

Handling user actions like clicks, typing, and form submission.

2. Which naming style is used in React events?

CamelCase.

Example:

onClick

3. What is Synthetic Event?

A cross-browser wrapper around native browser events.

4. Why use preventDefault()?

To stop default browser behavior like form refresh.