60
公开标注数
7
参与人数
2026-07-15 09:18:00
首次 Whisper
讨论活跃度
react.dev 近 17 周的公开 Whisper
少多
最新公开 Whisper
划选高亮2026-07-28 15:41:53
原文高亮摘录
“you shouldn’t change objects and arrays that you hold in the React state directly.”
Whisper 随想笔记
Wait, so I have to copy the whole array just to tweak one item? That feels wasteful but okay.
划选高亮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 12:38:53
原文高亮摘录
“Setting it does not change the state variable you already have, but instead triggers a re-render.”
Whisper 随想笔记
So it's like a photo, not a live video? Kinda makes sense but still weird.
划选高亮2026-07-28 12:29:53
原文高亮摘录
“Setting it does not change the state variable you already have, but instead triggers a re-render.”
Whisper 随想笔记
That's why my console.log always shows the old value right after setState, took me a while to get it.
划选高亮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.
划选高亮2026-07-28 09:35:53
原文高亮摘录
“In React, data that changes over time is called state.”
Whisper 随想笔记
reminds me of variables but with superpowers, nice explanation actually
划选高亮2026-07-28 09:26:53
原文高亮摘录
“In React, data that changes over time is called state.”
Whisper 随想笔记
i always thought state was only for forms, good to know it's broader
划选高亮2026-07-28 09:17:53
原文高亮摘录
“In React, data that changes over time is called state.”
Whisper 随想笔记
so basically state is just a fancy word for stuff that changes lol
划选高亮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 12:38:48
原文高亮摘录
“By strictly only writing your components as pure functions, you can avoid an entire class of baffling bugs”
Whisper 随想笔记
I've been burned by impure components before, this advice is gold.
划选高亮2026-07-27 12:29:48
原文高亮摘录
“By strictly only writing your components as pure functions, you can avoid an entire class of baffling bugs”
Whisper 随想笔记
Yeah but pure functions are hard when you need random values or time.
划选高亮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.
划选高亮2026-07-27 09:35:48
原文高亮摘录
“UI is built from small units like buttons, text, and images.”
Whisper 随想笔记
I always forget that even a whole page is just a bunch of tiny pieces.
划选高亮2026-07-27 09:26:48
原文高亮摘录
“UI is built from small units like buttons, text, and images.”
Whisper 随想笔记
Sounds obvious, but it's the foundation of everything in React.