We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 774265a commit 2e9ac00Copy full SHA for 2e9ac00
src/content/reference/rules/components-and-hooks-must-be-pure.md
@@ -49,7 +49,7 @@ function Dropdown() {
49
function Dropdown() {
50
const selectedItems = new Set();
51
const onSelect = (item) => {
52
- // 这段代码位于事件处理器中,因此只有在用户触发这个事件时才会运行。
+ // 这段代码位于事件处理函数中,因此只有在用户触发这个事件时才会运行。
53
selectedItems.add(item);
54
}
55
@@ -99,7 +99,7 @@ function useTime() {
99
useEffect(() => {
100
// 2. 使用 `setInterval` 每秒更新当前日期。
101
const id = setInterval(() => {
102
- setTime(new Date()); // ✅ Good:非幂等代码不再在渲染中运行。
+ setTime(new Date()); // ✅ 正确的:非幂等代码不再在渲染中运行。
103
}, 1000);
104
// 3. 返回一个清理函数,这样我们就不会忘记清理 `setInterval` 定时器,导致内存泄漏。
105
return () => clearInterval(id);
0 commit comments