-
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.
- Loading branch information
1 parent
c340be2
commit df07778
Showing
14 changed files
with
201 additions
and
146 deletions.
There are no files selected for viewing
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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './create-rsc-action-stream.js'; | ||
export * from './create-rsc-app-stream.js'; | ||
export * from './create-rsc-form-state.js'; | ||
export * from './use-postpone.js'; |
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,16 @@ | ||
import * as React from 'react'; | ||
import {requestContextAsyncLocalStorage} from '../shared/request-context-async-local-storage.js'; | ||
|
||
export function usePostpone(): void { | ||
const requestContext = requestContextAsyncLocalStorage.getStore(); | ||
|
||
if (!requestContext) { | ||
throw new Error( | ||
`usePostpone() was called outside of an asynchronous context initialized by calling requestContextAsyncLocalStorage.run()`, | ||
); | ||
} | ||
|
||
if (requestContext.isPrerender) { | ||
return React.unstable_postpone(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/core/src/server/shared/request-context-async-local-storage.ts
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,10 @@ | ||
import {AsyncLocalStorage} from 'node:async_hooks'; | ||
import type {RouterLocation} from '../../use-router-location.js'; | ||
|
||
export interface RequestContext { | ||
readonly routerLocation: RouterLocation; | ||
readonly isPrerender?: boolean; | ||
} | ||
|
||
export const requestContextAsyncLocalStorage = | ||
new AsyncLocalStorage<RequestContext>(); |
5 changes: 0 additions & 5 deletions
5
packages/core/src/server/shared/router-location-async-local-storage.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.