react.dev favicon

Synchronizing with Effects – React

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

本页的公开 Whisper

划选高亮2026-07-28 13:06:18
原文高亮摘录
Every time your component renders, React will update the screen and then run the code inside useEffect.
Whisper 随想笔记
Unless you pass deps, right? Then it only runs when those change, not every render.
划选高亮2026-07-28 12:57:18
原文高亮摘录
Every time your component renders, React will update the screen and then run the code inside useEffect.
Whisper 随想笔记
So the effect always runs after paint, not before? That's good to know for layout stuff.
划选高亮2026-07-28 10:03:18
原文高亮摘录
Effects let you specify side effects that are caused by rendering itself, rather than by a particular event.
Whisper 随想笔记
I remember debugging a chat app where I put the connection in an event—big mistake.
划选高亮2026-07-28 09:54:18
原文高亮摘录
Effects let you specify side effects that are caused by rendering itself, rather than by a particular event.
Whisper 随想笔记
Hmm, but doesn't that mean effects run on every render? Seems wasteful.
划选高亮2026-07-28 09:45:18
原文高亮摘录
Effects let you specify side effects that are caused by rendering itself, rather than by a particular event.
Whisper 随想笔记
This finally makes the event vs effect distinction click for me.

分享本页 Whisper

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

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

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

获取插件