Skip to content

Commit 9d92f8c

Browse files
committed
fix: add SsrUseWorkaround
1 parent d7194ee commit 9d92f8c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/plugin-rsc/examples/starter/src/framework/entry.ssr.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ export async function renderHTML(
2424
// deserialization needs to be kicked off inside ReactDOMServer context
2525
// for ReactDomServer preinit/preloading to work
2626
payload ??= ReactClient.createFromReadableStream<RscPayload>(rscStream1)
27-
return React.use(payload).root
27+
const root = React.use(payload).root
28+
return <SsrUseWorkaround>{root}</SsrUseWorkaround>
29+
}
30+
31+
// Add an empty component in between SsrRoot and user's root to avoid React SSR bugs.
32+
// > SsrRoot (use) -> SsrUseWorkaround -> root (which potentially has `lazy` + `use`)
33+
// https://github.com/facebook/react/issues/33937#issuecomment-3091349011
34+
function SsrUseWorkaround(props: React.PropsWithChildren) {
35+
return props.children
2836
}
2937

3038
// render html (traditional SSR)

0 commit comments

Comments
 (0)