MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Handling Synthetic Events in React0%
Study Materials
React.js for BeginnersProgress 0%
1.1Why React and Single-Page Architecture1.2Setting Up Modern React with Vite1.3React Project Directory Structure and Entry Points1.4Virtual DOM and React Render Cycle Explained
5.1Handling Synthetic Events in React5.2Passing Arguments to Event Handlers5.3Handling Click, Change, and Submit Events5.4Preventing Default Browser Behaviors
HomeTutorialsReact.js for BeginnersHandling Synthetic Events in React
Passing Arguments to Event Handlers

Handling Synthetic Events in React

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

1. What Are Synthetic Events?

In native browser JavaScript, event handling varies slightly across different browsers and operating systems (e.g., event bubbling details, property naming, mouse coordinates).

To ensure identical, consistent behavior across Chrome, Firefox, Safari, Edge, and mobile browsers, React wraps native browser events inside a cross-browser wrapper called the SyntheticEvent.

React's SyntheticEvent:

  • Provides the exact same standard interface across all browsers (conforming to the W3C event specification).
  • Standardizes properties like e.target, e.currentTarget, e.preventDefault(), and e.stopPropagation().
  • Retains access to the underlying browser native event via e.nativeEvent if low-level native properties are needed.

2. Event Handling Syntax: React vs HTML

There are three fundamental syntax differences between native HTML event listeners and React JSX event listeners:

Difference 1: CamelCase Naming

In HTML, event names are lowercase (onclick, onchange, onsubmit). In React JSX, event names must be camelCase (onClick, onChange, onSubmit, onKeyDown).

Difference 2: Function Reference vs String

In HTML, you pass a string of JavaScript code to execute. In React, you pass an actual function reference:

1<!-- Native HTML -->
2<button onclick="handleClick()">Submit</button>
3 
4<!-- React JSX -->
5<button onClick={handleClick}>Submit</button>

Difference 3: Function Reference vs Function Invocation

A classic beginner pitfall is accidentally calling the function instead of passing its reference:

1// ❌ WRONG: Calls handleClick immediately when the component renders!
2<button onClick={handleClick()}>Click Me</button>
3 
4// ✅ CORRECT: Passes the function reference to be called when clicked
5<button onClick={handleClick}>Click Me</button>
6 
7// ✅ CORRECT: Inline arrow function reference
8<button onClick={() => console.log('Clicked!')}>Click Me</button>

3. The Synthetic Event Object (e)

When an event triggers, React automatically passes the SyntheticEvent object as the first argument to your handler function:

1import React from 'react';
2 
3export default function ActionToolbar() {
4 const handleButtonClick = (e) => {
5 console.log('Event type:', e.type); // 'click'
6 console.log('Target element:', e.target); // <button> node
7 console.log('Shift key pressed?:', e.shiftKey); // true/false
8 };
9 
10 const handleInputChange = (e) => {
11 console.log('Input value:', e.target.value); // current input text
12 };
13 
14 return (
15 <div>
16 <input type="text" onChange={handleInputChange} />
17 <button onClick={handleButtonClick}>Execute Action</button>
18 </div>
19 );
20}

4. Event Delegation in React

You might wonder: does attaching onClick to 1,000 list items create 1,000 separate event listeners in browser memory?

No! React utilizes Event Delegation. In modern React (React 17+), React attaches a single top-level event listener for each event type at the root DOM container (<div id="root">). When an event bubbles up to the root, React maps the event to the appropriate component and dispatches the SyntheticEvent. This delivers exceptional performance and minimal memory footprint.


Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What is a SyntheticEvent in React?
Question 2
How are event handler attributes formatted in React JSX?
Question 3
What is wrong with writing <button onClick={alert('Saved!')}>Save</button> in JSX?
Question 4
How does React achieve high performance when thousands of elements have event handlers attached?
Question 5
How can you access the browser's raw, underlying native event from React's SyntheticEvent?
Next Lesson

Passing Arguments to Event Handlers

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Lifting State Up Between SiblingsPassing Arguments to Event Handlers

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master React.js for Beginners with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext