Skip to content

Commit a979841

Browse files
author
Google
committed
fix: docs give conflict answers about when effects will run
1 parent a3e9466 commit a979841

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/content/reference/rules/components-and-hooks-must-be-pure.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Concretely, this means that rendering logic can be run multiple times in a way t
2828

2929
React is declarative: you tell React _what_ to render, and React will figure out _how_ best to display it to your user. To do this, React has a few phases where it runs your code. You don't need to know about all of these phases to use React well. But at a high level, you should know about what code runs in _render_, and what runs outside of it.
3030

31-
_Rendering_ refers to calculating what the next version of your UI should look like. After rendering, [Effects](/reference/react/useEffect) are _flushed_ (meaning they are run until there are no more left) and may update the calculation if the Effects have impacts on layout. React takes this new calculation and compares it to the calculation used to create the previous version of your UI, then _commits_ just the minimum changes needed to the [DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model) (what your user actually sees) to catch it up to the latest version.
31+
_Rendering_ refers to calculating what the next version of your UI should look like.Rendering refers to calculating what the next version of your UI should look like. After rendering, React compares this result to the previous one and commits the minimum necessary changes to the [DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model) (what your user actually sees). Then, [Effects](/reference/react/useEffect) are flushed — meaning they are executed after the commit phase is complete.
32+
3233

3334
<DeepDive>
3435

0 commit comments

Comments
 (0)