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";
5
5
import { createStaticRouter , StaticRouterProvider } from "../dom/server" ;
6
6
import { injectRSCPayload } from "./html-stream/server" ;
7
7
import { RSCRouterGlobalErrorBoundary } from "./errorBoundaries" ;
8
+ import { shouldHydrateRouteLoader } from "../dom/ssr/routes" ;
8
9
import type { RSCPayload } from "./server.rsc" ;
9
10
10
11
export type SSRCreateFromReadableStreamFunction = (
@@ -112,12 +113,27 @@ export function RSCStaticRouter({
112
113
113
114
if ( payload . type !== "render" ) return null ;
114
115
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
+
115
131
const context = {
116
132
actionData : payload . actionData ,
117
133
actionHeaders : { } ,
118
134
basename : payload . basename ,
119
135
errors : payload . errors ,
120
- loaderData : payload . loaderData ,
136
+ loaderData : patchedLoaderData ,
121
137
loaderHeaders : { } ,
122
138
location : payload . location ,
123
139
statusCode : 200 ,
You can’t perform that action at this time.
0 commit comments