Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/content/learn/separating-events-from-effects.md
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ function Timer() {
setCount(count + 1);
});

useTimer(onTick, 1000); // 🔴 Avoid: 传递 Effect Event
useTimer(onTick, 1000); // 🔴 避免: 传递 Effect Event

return <h1>{count}</h1>
}
Expand All @@ -912,7 +912,7 @@ function useTimer(callback, delay) {
return () => {
clearInterval(id);
};
}, [delay, callback]); // 需要在依赖项中指定“callback”
}, [delay, callback]); // 需要在依赖项中指定 “callback”
}
```

Expand All @@ -934,7 +934,7 @@ function useTimer(callback, delay) {

useEffect(() => {
const id = setInterval(() => {
onTick(); // ✅ Good: 只在 Effect 内部局部调用
onTick(); // ✅ : 只在 Effect 内部局部调用
}, delay);
return () => {
clearInterval(id);
Expand Down