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
Mount the component using ReactDOM.render, and you will never observe the component with its initial state ("Loading..."). Only the updated state ("Ready").
Mount the component with createRoot and root.render, and you will observe the component render twice. Once with the initial state ("Loading..."), then with the updated state ("Ready").
Recreating #28457, which was closed due to staleness.
Maybe a weird edge case, but this caused an unexpected visual change in our app when migrating a root from
ReactDOM.render
.React version: 18.2.0
Steps To Reproduce
useLayoutEffect
that modifies the state in arequestAnimationFrame
callback. like:ReactDOM.render
, and you will never observe the component with its initial state ("Loading..."). Only the updated state ("Ready").createRoot
androot.render
, and you will observe the component render twice. Once with the initial state ("Loading..."), then with the updated state ("Ready").Link to code example: https://codepen.io/mxmul/pen/abMexLe
react-batching.webm
The current behavior
Two renders - once with the initial state, and a second with the updated state.
The expected behavior
A single render with the updated state. This seems to be the behavior before React 18.
The text was updated successfully, but these errors were encountered: