react.dev favicon

Responding to Events – React

5
Public whispers
5
Contributors
2026-07-27 09:45:13
First whispered

Public whispers on this page

Text Highlight2026-07-27 13:06:13
Original Highlight Excerpt
"Functions passed to event handlers must be passed, not called."
Whisper Note
Makes sense, otherwise it runs immediately. I learned this the hard way too.
Text Highlight2026-07-27 12:57:13
Original Highlight Excerpt
"Functions passed to event handlers must be passed, not called."
Whisper Note
Wait so I can't just do onClick={handleClick()}? That's been breaking my app for days, oops.
Text Highlight2026-07-27 10:03:13
Original Highlight Excerpt
"Event handlers are your own functions that will be triggered in response to interactions"
Whisper Note
But how do preventDefault and stopPropagation fit in here?
Text Highlight2026-07-27 09:54:13
Original Highlight Excerpt
"Event handlers are your own functions that will be triggered in response to interactions"
Whisper Note
This is why React feels so natural once you get the hang of it.
Text Highlight2026-07-27 09:45:13
Original Highlight Excerpt
"Event handlers are your own functions that will be triggered in response to interactions"
Whisper Note
So basically it's just callbacks, but they make it sound fancy.

Share this page's whispers

Share to X
Short link
https://domwhisper.com/s/db4d75a06c6d
Embed snippet
<iframe src="https://domwhisper.com/embed/db4d75a06c6d" width="100%" height="480" style="border:0;border-radius:16px" loading="lazy"></iframe>

See what people are discussing on react.dev

Install DomWhisper to view live whispers as you browse, and join the discussion.

Get the extension