mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-26 07:25:20 +00:00
tweak
This commit is contained in:
@@ -856,4 +856,4 @@ button { margin-bottom: 10px; }
|
||||
|
||||
Note that derived state must set be inside a condition like `prevCount !== count`, and there must be a call like `setPrevCount(count)` inside of it. Otherwise, your component would re-render in a loop until it crashes.
|
||||
|
||||
If you can, try to avoid derived state. However, derived state is better than updating state in an effect. When you call the `set` function during render, React will render that component immediately after your component exits with a `return` statement. React will ignore the initial output so it won't need to render the children twice.
|
||||
If you can, try to avoid derived state. However, derived state is better than updating state in an effect. When you call the `set` function during render, React will re-render that component immediately after your component exits with a `return` statement, and before rendering the children. This way, children don't need to render twice.
|
||||
|
||||
Reference in New Issue
Block a user