@@ -6,6 +6,7 @@ import type {
66 StaticHandlerContext ,
77 CreateStaticHandlerOptions as RouterCreateStaticHandlerOptions ,
88 UNSAFE_RouteManifest as RouteManifest ,
9+ RouterState ,
910} from "@remix-run/router" ;
1011import {
1112 IDLE_BLOCKER ,
@@ -17,7 +18,10 @@ import {
1718 createStaticHandler as routerCreateStaticHandler ,
1819 UNSAFE_convertRoutesToDataRoutes as convertRoutesToDataRoutes ,
1920} from "@remix-run/router" ;
20- import { UNSAFE_mapRouteProperties as mapRouteProperties } from "react-router" ;
21+ import {
22+ UNSAFE_mapRouteProperties as mapRouteProperties ,
23+ UNSAFE_useRoutesImpl as useRoutesImpl ,
24+ } from "react-router" ;
2125import type {
2226 DataRouteObject ,
2327 Location ,
@@ -28,7 +32,6 @@ import {
2832 createPath ,
2933 parsePath ,
3034 Router ,
31- useRoutes ,
3235 UNSAFE_DataRouterContext as DataRouterContext ,
3336 UNSAFE_DataRouterStateContext as DataRouterStateContext ,
3437} from "react-router-dom" ;
@@ -122,17 +125,19 @@ export function StaticRouterProvider({
122125 hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${ json } );` ;
123126 }
124127
128+ let { state } = dataRouterContext . router ;
129+
125130 return (
126131 < >
127132 < DataRouterContext . Provider value = { dataRouterContext } >
128- < DataRouterStateContext . Provider value = { dataRouterContext . router . state } >
133+ < DataRouterStateContext . Provider value = { state } >
129134 < Router
130135 basename = { dataRouterContext . basename }
131- location = { dataRouterContext . router . state . location }
132- navigationType = { dataRouterContext . router . state . historyAction }
136+ location = { state . location }
137+ navigationType = { state . historyAction }
133138 navigator = { dataRouterContext . navigator }
134139 >
135- < DataRoutes routes = { router . routes } />
140+ < DataRoutes routes = { router . routes } state = { state } />
136141 </ Router >
137142 </ DataRouterStateContext . Provider >
138143 </ DataRouterContext . Provider >
@@ -149,10 +154,12 @@ export function StaticRouterProvider({
149154
150155function DataRoutes ( {
151156 routes,
157+ state,
152158} : {
153159 routes : DataRouteObject [ ] ;
160+ state : RouterState ;
154161} ) : React . ReactElement | null {
155- return useRoutes ( routes ) ;
162+ return useRoutesImpl ( routes , undefined , state ) ;
156163}
157164
158165function serializeErrors (
0 commit comments