react.dev favicon

Responding to Events – React

5
公开标注数
5
参与人数
2026-07-27 09:45:13
首次 Whisper

本页的公开 Whisper

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

分享本页 Whisper

分享到 X
短链接
https://domwhisper.com/s/db4d75a06c6d
嵌入代码
<iframe src="https://domwhisper.com/embed/db4d75a06c6d" width="100%" height="480" style="border:0;border-radius:16px" loading="lazy"></iframe>

看看大家在 react.dev 上讨论了什么

安装 DomWhisper,浏览网页时实时查看 whisper,也可以加入讨论。

获取插件