From da73ddc604b4e001610c1d9803f6beb9c0ea87a5 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Mon, 6 Nov 2023 14:30:18 +0700 Subject: [PATCH 1/2] chore(ssr): Move LocationProvider inside framework for ssr --- .../streamingSsr/entry.server.tsx.template | 11 ++++------- packages/vite/src/streaming/streamHelpers.ts | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/commands/experimental/templates/streamingSsr/entry.server.tsx.template b/packages/cli/src/commands/experimental/templates/streamingSsr/entry.server.tsx.template index fda9b9b6a01c..c7d7e5af9814 100644 --- a/packages/cli/src/commands/experimental/templates/streamingSsr/entry.server.tsx.template +++ b/packages/cli/src/commands/experimental/templates/streamingSsr/entry.server.tsx.template @@ -4,17 +4,14 @@ import App from './App' import { Document } from './Document' interface Props { - url: string css: string[] meta?: any[] } -export const ServerEntry: React.FC = ({ url, css, meta }) => { +export const ServerEntry: React.FC = ({ css, meta }) => { return ( - - - - - + + + ) } diff --git a/packages/vite/src/streaming/streamHelpers.ts b/packages/vite/src/streaming/streamHelpers.ts index e92e9038c624..910e635eb5b4 100644 --- a/packages/vite/src/streaming/streamHelpers.ts +++ b/packages/vite/src/streaming/streamHelpers.ts @@ -7,6 +7,7 @@ import type { ReactDOMServerReadableStream, } from 'react-dom/server' +import { LocationProvider } from '@redwoodjs/router' import type { TagDescriptor } from '@redwoodjs/web' // @TODO (ESM), use exports field. Cannot import from web because of index exports import { @@ -88,11 +89,19 @@ export async function reactRenderToStreamResponse( { value: injectToPage, }, - ServerEntry({ - url: path, - css: cssLinks, - meta: metaTags, - }) + React.createElement( + LocationProvider, + { + location: { + pathname: path, + }, + }, + ServerEntry({ + url: path, + css: cssLinks, + meta: metaTags, + }) + ) ) } From 8a3449519668ffe81ea1ea9cd62aa452fcc1b6c1 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Mon, 6 Nov 2023 15:30:18 +0700 Subject: [PATCH 2/2] Lint --- .../templates/streamingSsr/entry.server.tsx.template | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/cli/src/commands/experimental/templates/streamingSsr/entry.server.tsx.template b/packages/cli/src/commands/experimental/templates/streamingSsr/entry.server.tsx.template index c7d7e5af9814..a52b268b771d 100644 --- a/packages/cli/src/commands/experimental/templates/streamingSsr/entry.server.tsx.template +++ b/packages/cli/src/commands/experimental/templates/streamingSsr/entry.server.tsx.template @@ -1,5 +1,3 @@ -import { LocationProvider } from '@redwoodjs/router' - import App from './App' import { Document } from './Document'