File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
packages/react-router/lib/rsc Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import type { FrameworkContextObject } from "../dom/ssr/entry";
55import { createStaticRouter , StaticRouterProvider } from "../dom/server" ;
66import { injectRSCPayload } from "./html-stream/server" ;
77import { RSCRouterGlobalErrorBoundary } from "./errorBoundaries" ;
8+ import { shouldHydrateRouteLoader } from "../dom/ssr/routes" ;
89import type { RSCPayload } from "./server.rsc" ;
910
1011export type SSRCreateFromReadableStreamFunction = (
@@ -112,12 +113,27 @@ export function RSCStaticRouter({
112113
113114 if ( payload . type !== "render" ) return null ;
114115
116+ let patchedLoaderData = { ...payload . loaderData } ;
117+ for ( const match of payload . matches ) {
118+ if (
119+ shouldHydrateRouteLoader (
120+ match . id ,
121+ match . clientLoader ,
122+ match . hasLoader ,
123+ false
124+ ) &&
125+ ( match . hydrateFallbackElement || ! match . hasLoader )
126+ ) {
127+ delete patchedLoaderData [ match . id ] ;
128+ }
129+ }
130+
115131 const context = {
116132 actionData : payload . actionData ,
117133 actionHeaders : { } ,
118134 basename : payload . basename ,
119135 errors : payload . errors ,
120- loaderData : payload . loaderData ,
136+ loaderData : patchedLoaderData ,
121137 loaderHeaders : { } ,
122138 location : payload . location ,
123139 statusCode : 200 ,
You can’t perform that action at this time.
0 commit comments