Whatever is in the curly braces is what is returned to the listener. The listener is expecting a function that will be called when the event is fired.

  1. onClick={handleDelete(id)}

This won't work because you're calling handleDelete immediately and assigning the result of calling that function to the listener. That function may return an explicit value or undefined (note: that explicit value may be a a new function (closure) which can be assigned to the listener - but in this case I doubt this is happening).

  1. onClick={() => handleDelete(id)}

This will work because you're assigning a function to the listener, and when the event is fired it will call that function which, in turn, will call handleDelete(id).

  1. onClick={handleDelete}

This will also work because you're passing a reference to the handleDelete function to the listener, and that function will get called when the event is fired.

(Note: doing it this way would mean that the component would need to be rewritten to have a data-id attribute that the function can pick up because you're no longer sending an explicit id argument to handleDelete when you call it.)

Answer from Andy on Stack Overflow
🌐
React
react.dev › learn › responding-to-events
Responding to Events – React
If you click on either button, its onClick will run first, followed by the parent <div>’s onClick. So two messages will appear. If you click the toolbar itself, only the parent <div>’s onClick will run. All events propagate in React except onScroll, which only works on the JSX tag you attach it to.
🌐
React
legacy.reactjs.org › docs › handling-events.html
Handling Events – React
Generally, if you refer to a method without () after it, such as onClick={this.handleClick}, you should bind that method. If calling bind annoys you, there are two ways you can get around this. You can use public class fields syntax to correctly bind callbacks: class LoggingButton extends React.Component { // This syntax ensures `this` is bound within handleClick.
People also ask

How to handle multiple button onClick events in React?
You can handle multiple button onClick events using a single handler function. Pass arguments to identify the clicked button (e.g., button ID, data attribute) or use event delegation from a parent element.
🌐
angularminds.com
angularminds.com › blog › react-onclick-event-handlers-a-complete-guide
React onClick event handlers: A complete guide
How to trigger a click event in a React functional component?
To trigger a click event programmatically in a React functional component, get a ref to the DOM element (useRef) and then call its .click() method (e.g., buttonRef.current.click()).
🌐
angularminds.com
angularminds.com › blog › react-onclick-event-handlers-a-complete-guide
React onClick event handlers: A complete guide
What is the event target in React?
In React, event.target refers to the specific DOM element that triggered the event. For example, in an onClick on a button, event.target would be that button element itself.
🌐
angularminds.com
angularminds.com › blog › react-onclick-event-handlers-a-complete-guide
React onClick event handlers: A complete guide
🌐
W3Schools
w3schools.com › react › react_events.asp
React Events
React events are written in camelCase syntax: onClick instead of onclick. React event handlers are written inside curly braces: onClick={shoot} instead of onclick="shoot()".
🌐
LogRocket
blog.logrocket.com › home › react onclick event handlers: a complete guide
React onClick event handlers: A complete guide - LogRocket Blog
December 10, 2024 - This guide covers React’s onClick event handler, including information about event listening, synthetic events, custom events, and more.
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › react-onclick-event
React onClick Event - GeeksforGeeks
November 29, 2024 - The onClick event in React is used for handling a function when an element, such as a button, div, or any clickable element, is clicked.
🌐
SheCodes
shecodes.io › athena › 10997-how-to-add-an-onclick-event-in-react
[React] - How to Add an Onclick Event in React - SheCodes | SheCodes
Learn how to use the onclick attribute and arrow functions to add an onclick event to your react components.
Find elsewhere
🌐
Angular Minds
angularminds.com › blog › react-onclick-event-handlers-a-complete-guide
React onClick event handlers: A complete guide
June 19, 2024 - Brief: This comprehensive guide dives into React’s onClick event handlers, a core feature for building interactive user interfaces. This is Perfect for developers aiming to create responsive, accessible, and dynamic React applications.
🌐
Upmostly
upmostly.com › home › tutorials › react onclick event handling (with examples)
React onClick Event Handling (With Examples) - Upmostly
March 10, 2022 - In React, the onClick handler allows you to call a function and perform an action when an element is clicked. onClick is the cornerstone of any React app.
🌐
Medium
medium.com › @fslunsky › reacts-event-handling-why-your-onclick-isn-t-clicking-1c136a0f3f7b
React’s Event Handling: Why Your onClick Isn’t Clicking | by Fslunsky | Medium
April 26, 2025 - On top of that, React doesn’t attach your event listeners directly to each DOM element (like Vanilla JS does). Instead, it uses event delegation — your events are registered at the root of the DOM tree and then bubble up to where you need them. Cool, right? Except when it breaks and you spend 45 minutes yelling at your onClick, which is still just sitting there, silently mocking you.
🌐
TatvaSoft
tatvasoft.com › home › how to use react onclick event handler?
How to Use React OnClick Event Handler? - TatvaSoft Blog
February 4, 2025 - Event handlers play a crucial role in determining what actions to take as a response to specific events. The React’s onClick event handler helps handle click events on DOM elements effectively.
🌐
DEV Community
dev.to › ahmad_mahboob › handling-click-events-in-react-a-beginners-guide-to-onclick-2c2f
Handling Click Events in React: A Beginner’s Guide to onClick - DEV Community
December 28, 2025 - ... Now the function runs only when the button is clicked. ... Avoiding these mistakes will save a lot of time. Handling events is a core part of React. The onClick event helps us respond to user actions like button clicks.
🌐
React
react.dev › learn › adding-interactivity
Adding Interactivity – React
import { useState } from 'react'; export default function Counter() { const [score, setScore] = useState(0); function increment() { setScore(score + 1); } return ( <> <button onClick={() => increment()}>+1</button> <button onClick={() => { increment(); increment(); increment(); }}>+3</button> <h1>Score: {score}</h1> </> ) }
🌐
Newline
newline.co › @andreeamaco › how-to-use-react-onclick-events-in-class-and-functional-components--fb63a01e
How to Use React onClick Events in Class and Functional Components
June 23, 2020 - In this article, we’ll cover the basics of React onClick events and we’ll learn to handle click events in class and functional components. We’ll discuss the differences between JavaScript and React click events, the syntax of event handlers, and binding event handlers to the this keyword.
🌐
Blog Example
admiral-studios.com › blog › how-to-use-onclick-event-in-reactjs
How to Use the react onClick Event in React.js - Admiral Studios
January 6, 2025 - You can also pass functions with parameters to the onClick event. Instead of directly referencing the function, you wrap it in an anonymous arrow function. For example: ... In this example, clicking the button triggers the sayHello function, passing the name parameter. The React Native onClick handler works similarly but is adapted for touch-based interfaces in mobile applications, showcasing the flexibility of React's event system.
🌐
Simplilearn
simplilearn.com › home › resources › software development › understand reactjs onclick event handler in detail
Understand Reactjs onClick Event Handler in detail | Simplilearn
June 9, 2025 - Learn how onClick event handler plays a very important role in ReactJS. Also learn to use the onClick events in function components in different ways. Read Now!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Upmostly
upmostly.com › home › tutorials › pass a parameter through onclick in react
Pass a Parameter Through onClick in React - Upmostly
October 28, 2021 - It’s a single button with one event handler: onClick. Typically, to call a function when we click a button in React, we would simply pass in the name of the function to the onClick handler, like so:
🌐
Felix Gerschau
felixgerschau.com › react-typescript-onclick-event-type
TypeScript definition for onClick React event
import React, { MouseEvent } from 'react'; const ButtonComponent = () => { const handleMouseEvent = (e: MouseEvent<HTMLButtonElement>) => { e.preventDefault(); // Do something }; return <button onClick={handleMouseEvent}>Click me!</button>; }; export default ButtonComponent; onAuxClick ·
🌐
Reddit
reddit.com › r/learnprogramming › onclick function with parameters in react
r/learnprogramming on Reddit: onClick function with parameters in react
March 24, 2024 -

Hey, how's it going?

I am working on a react app to play a card game. When a user clicks a card, I want it to trigger an onClick function that is mostly the same but slightly different for each card. Is there a way to assign onClick functions with parameters to do this?

If I do something like onClick={handleClick(parameter)}, it assigns the result of the function call to onClick, which is not what I want. Currently, as a workaround, I have a function which builds other functions that use the correct parameters like this:

function handleClick(parameter) {return () => {console.log(parameter)} }

but I would like a cleaner solution. If every card has a unique onClick I end up making like 20 anonymous functions that all do basically the same thing everytime my component re-renders, which feels messy and gross.

Does anyone know a way to do this, or is it not possible?