-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace server context with
AsyncLocalStorage
and client context
Because [server context has been deprecated](facebook/react#27424), we needed to find a replacement for sharing the current location. Using conditional exports, we can create a universal `useRouterLocation` hook that utilizes `AsyncLocalStorage` on the server, and normal client context in the browser. Even though the client context would also be accessible in the SSR client (we could render the context provider in `ServerRoot`), we are instead using `AsyncLocalStorage` here as well, primarily for its convenience. Although this does require placing the module containing the `AsyncLocalStorage` instance into a shared webpack layer.
- Loading branch information
1 parent
603f17b
commit 0219e49
Showing
25 changed files
with
187 additions
and
172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This is in a separate file so that we can configure webpack to use the | ||
// `react-server` layer for this module, and therefore the imported modules | ||
// (React and the server components) will be imported with the required | ||
// `react-server` condition. | ||
|
||
import {App} from '@mfng/shared-app/app.js'; | ||
import * as React from 'react'; | ||
|
||
export function createRscApp(): React.ReactNode { | ||
return <App getTitle={(pathname) => `Cloudflare RSC/SSR demo ${pathname}`} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
apps/vercel-app/src/edge-function-handler/create-rsc-app-options.tsx
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
apps/vercel-app/src/edge-function-handler/create-rsc-app.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// This is in a separate file so that we can configure webpack to use the | ||
// `react-server` layer for this module, and therefore the imported modules | ||
// (React and the server components) will be imported with the required | ||
// `react-server` condition. | ||
|
||
import {App} from '@mfng/shared-app/app.js'; | ||
import * as React from 'react'; | ||
|
||
export function createRscApp(): React.ReactNode { | ||
return ( | ||
<App getTitle={(pathname) => `Vercel Edge RSC/SSR demo ${pathname}`} /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.