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()".
🌐
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.
🌐
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.
🌐
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
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.
🌐
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.
🌐
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.
🌐
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> </> ) }
🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
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 ·
🌐
Medium
medium.com › @rastogi.programmer › react-event-handling-master-onclick-onchange-and-more-d449b438a177
React Event Handling — Master onClick, onChange, and More | by Vivek Rastogi | Medium
July 6, 2025 - React handles these using camelCase event names and JSX syntax. Let’s start with the most common event: clicking a button. function ClickExample() { const handleClick = () => { alert("Button was clicked!"); }; return <button onClick={handleClick}>Click Me</button>; }
Top answer
1 of 2
140

This depends on your SensorItem component's definition. Because SensorItem isn't a native DOM element but, like you said, another React component, onClick as defined here is simply a property of that component. What you need to do is, inside of the SensorItem component pass the onClick prop to an DOM component's onClick event:

var SensorItem = React.createClass({
  render: function() {
    return (
      <div className="SensorItem" onClick={this.props.onClick}>
       ...
      </div>
    );
  }
});
2 of 2
30

Problem

The problem, as being explained in another answer, is that onClick on a <SensorItem> React component (contrary to native DOM element like <div> or <p>) is treated as passing of component property, and not of a DOM event handler. And as most likely your <SensorItem> component doesn't declare onClick property, that property value simply gets lost.

Solution

The most straightforward solution is to add onClick property explicitly on SensorItem component, then pass it to the root DOM element of that component:

function SensorItem({ prop1, prop2, onClick }) {
  (...)

  return (
    <p onClick={onClick}>
      (...)
    </p>
  );
}

But the solution that usually works best for me is to group all the undefined component's properties using object destructuring notation, then pass them all to the root DOM element within that component. This way you can pass onClick, onHover, className etc. without needing to define separate properties for each one of them:

function SensorItem({ prop1, prop2, ...rootDOMAttributes }) {
  (...)

  return (
    <p {...rootDOMAttributes}>
      (...)
    </p>
  );
}

No matter which of the two approaches you use, the handler will now work, as it'll now be attached to the root DOM element of SensorItem:

<SensorItem onClick={...} />