Event Handlers in React
From the React Components & JSX cheat sheet · Component Essentials · verified Jul 2026
Event Handlers
Handle user interactions with events
javascript
// Click event
function Button() {
const handleClick = () => {
alert('Clicked!')
}
return <button onClick={handleClick}>Click me</button>
}
// Event with parameters
function Item({ id, name, onDelete }) {
return (
<div>
<span>{name}</span>
<button onClick={() => onDelete(id)}>Delete</button>
</div>
)
}
// Using the component
function App() {
const handleDelete = (itemId) => {
console.log('Deleting:', itemId)
}
return <Item id={1} name="Task" onDelete={handleDelete} />
}🟢 Essential - Events enable interactivity
💡 Use arrow functions to pass parameters
⚠️ Don't call the function: onClick={handleClick} not onClick={handleClick()}
eventshandlersessential