You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suggest it should be mentioned as caveat/pitfall that if you call await inside an event handler,
all changes made to states before that await will then be flushed and trigger a rerender immediately, not waiting
for the event handler to finish completely.
The text was updated successfully, but these errors were encountered:
0815Hunter
changed the title
[Suggestion]: Section "Queueing a Series of State Updates": await in event handler cause rerender
[Suggestion]: Section "Queueing a Series of State Updates": await in event handler cause immediate rerender
Jun 5, 2024
Summary
The documentation says here: "React waits until all code in the event handlers has run before processing your state updates"
This not the case when using
await
inside the handler!Example
This will rerender the component twice!
Page
https://react.dev/learn/queueing-a-series-of-state-updates
Details
I suggest it should be mentioned as caveat/pitfall that if you call
await
inside an event handler,all changes made to states before that
await
will then be flushed and trigger a rerender immediately, not waitingfor the event handler to finish completely.
The text was updated successfully, but these errors were encountered: