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
In React, the second state update ("bar") is rendered first, followed by the first update ("foo"). This reordering occurs only when the awaited function returns immediately. If the awaited promise resolves later, the state updates in the expected order.
In the example, you can observe this by clicking the button and checking the console for the message "BUG RENDERED!!!shockshockshock", or by noticing a brief red flash on the component when it renders incorrectly. The console message appears every time, while the red flash happens occasionally. In our actual app, the incorrect render occurs consistently.
If you modify the example to call await optionalDelay(true), the state updates will be applied in order, and the component will flash green.
The text was updated successfully, but these errors were encountered:
Summary
Steps To Reproduce :
The current behavior :
In React, the second state update ("bar") is rendered first, followed by the first update ("foo"). This reordering occurs only when the awaited function returns immediately. If the awaited promise resolves later, the state updates in the expected order.
In the example, you can observe this by clicking the button and checking the console for the message "BUG RENDERED!!!shockshockshock", or by noticing a brief red flash on the component when it renders incorrectly. The console message appears every time, while the red flash happens occasionally. In our actual app, the incorrect render occurs consistently.
If you modify the example to call await optionalDelay(true), the state updates will be applied in order, and the component will flash green.
The text was updated successfully, but these errors were encountered: