File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
packages/react-router/lib Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -667,6 +667,16 @@ export function RouterProvider({
667667 // pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
668668 React . useLayoutEffect ( ( ) => router . subscribe ( setState ) , [ router , setState ] ) ;
669669
670+ // Track race conditions where we finish initializing prior to the layout
671+ // effect above running to register our listener. If we manually detect a
672+ // change in `state.initialized`, automatically sync state.
673+ let initialized = state . initialized ;
674+ React . useLayoutEffect ( ( ) => {
675+ if ( ! initialized && router . state . initialized ) {
676+ logErrorsAndSetState ( router . state ) ;
677+ }
678+ } , [ initialized , logErrorsAndSetState , router . state ] ) ;
679+
670680 // When we start a view transition, create a Deferred we can use for the
671681 // eventual "completed" render
672682 React . useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments