Skip to content

Commit 56f65cc

Browse files
Update explanation of React state updates
Clarify timing of state updates in React. I was not sure based on the text if calling this function multiple times is a mistake, because if the update could happen before the current component function is finished, then it's a concurrency issue. (The word asynchronous lead me to think that.) Checking the react docs it seems to be the case that this never happens, the updates are done in between the 2 component runs.
1 parent 070deb3 commit 56f65cc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/content/1/en/part1d.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ Even though a new value was set for _left_ by calling _setLeft(left + 1)_, the o
315315
setTotal(left + right)
316316
```
317317

318-
The reason for this is that a state update in React happens [asynchronously](https://react.dev/learn/queueing-a-series-of-state-updates), i.e. not immediately but "at some point" before the component is rendered again.
318+
The reason for this is that a state update in React happens [asynchronously](https://react.dev/learn/queueing-a-series-of-state-updates), i.e. not immediately but "at some point" after the current component function is finished, before the component is rendered again.
319319

320320
We can fix the app as follows:
321321

0 commit comments

Comments
 (0)