Browse Source

docs: fix typo in useState Adjusting derived state section (#4300)

main
Humberto 3 years ago
committed by GitHub
parent
commit
b86f35d87a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      beta/src/pages/apis/usestate.md

2
beta/src/pages/apis/usestate.md

@ -853,6 +853,6 @@ button { margin-bottom: 10px; }
</Sandpack>
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.
Note that derived state must be set 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 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.

Loading…
Cancel
Save