diff --git a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js index f96b2724555cb..1ce1150423e4e 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js @@ -15,7 +15,6 @@ import ReactVersion from 'shared/ReactVersion'; import { createRequest, - resumeRequest, startWork, startFlowing, abort, @@ -166,13 +165,15 @@ function resume( allReady.catch(() => {}); reject(error); } - const request = resumeRequest( + const request = createRequest( children, - postponedState, + postponedState.resumableState, createRenderState( postponedState.resumableState, options ? options.nonce : undefined, ), + postponedState.rootFormatContext, + postponedState.progressiveChunkSize, options ? options.onError : undefined, onAllReady, onShellReady, diff --git a/packages/react-dom/src/server/ReactDOMFizzServerEdge.js b/packages/react-dom/src/server/ReactDOMFizzServerEdge.js index f96b2724555cb..1ce1150423e4e 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerEdge.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerEdge.js @@ -15,7 +15,6 @@ import ReactVersion from 'shared/ReactVersion'; import { createRequest, - resumeRequest, startWork, startFlowing, abort, @@ -166,13 +165,15 @@ function resume( allReady.catch(() => {}); reject(error); } - const request = resumeRequest( + const request = createRequest( children, - postponedState, + postponedState.resumableState, createRenderState( postponedState.resumableState, options ? options.nonce : undefined, ), + postponedState.rootFormatContext, + postponedState.progressiveChunkSize, options ? options.onError : undefined, onAllReady, onShellReady, diff --git a/packages/react-dom/src/server/ReactDOMFizzServerNode.js b/packages/react-dom/src/server/ReactDOMFizzServerNode.js index 35b125a9d6be7..ca4853a1533f7 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerNode.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerNode.js @@ -17,7 +17,6 @@ import ReactVersion from 'shared/ReactVersion'; import { createRequest, - resumeRequest, startWork, startFlowing, abort, @@ -135,13 +134,15 @@ function resumeRequestImpl( postponedState: PostponedState, options: void | ResumeOptions, ) { - return resumeRequest( + return createRequest( children, - postponedState, + postponedState.resumableState, createRenderState( postponedState.resumableState, options ? options.nonce : undefined, ), + postponedState.rootFormatContext, + postponedState.progressiveChunkSize, options ? options.onError : undefined, options ? options.onAllReady : undefined, options ? options.onShellReady : undefined, diff --git a/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js b/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js index de96c3616c63a..de603b20ac8e9 100644 --- a/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js +++ b/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js @@ -14,7 +14,7 @@ import type {PostponedState} from 'react-server/src/ReactFizzServer'; import ReactVersion from 'shared/ReactVersion'; import { - createPrerenderRequest, + createRequest, startWork, startFlowing, abort, @@ -78,7 +78,7 @@ function prerender( options ? options.bootstrapModules : undefined, options ? options.unstable_externalRuntimeSrc : undefined, ); - const request = createPrerenderRequest( + const request = createRequest( children, resources, createRenderState(resources, undefined), @@ -86,6 +86,8 @@ function prerender( options ? options.progressiveChunkSize : undefined, options ? options.onError : undefined, onAllReady, + undefined, + undefined, onFatalError, options ? options.onPostpone : undefined, ); diff --git a/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js b/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js index de96c3616c63a..de603b20ac8e9 100644 --- a/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js +++ b/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js @@ -14,7 +14,7 @@ import type {PostponedState} from 'react-server/src/ReactFizzServer'; import ReactVersion from 'shared/ReactVersion'; import { - createPrerenderRequest, + createRequest, startWork, startFlowing, abort, @@ -78,7 +78,7 @@ function prerender( options ? options.bootstrapModules : undefined, options ? options.unstable_externalRuntimeSrc : undefined, ); - const request = createPrerenderRequest( + const request = createRequest( children, resources, createRenderState(resources, undefined), @@ -86,6 +86,8 @@ function prerender( options ? options.progressiveChunkSize : undefined, options ? options.onError : undefined, onAllReady, + undefined, + undefined, onFatalError, options ? options.onPostpone : undefined, ); diff --git a/packages/react-dom/src/server/ReactDOMFizzStaticNode.js b/packages/react-dom/src/server/ReactDOMFizzStaticNode.js index b166d0a08c734..d22e1ea2d06f2 100644 --- a/packages/react-dom/src/server/ReactDOMFizzStaticNode.js +++ b/packages/react-dom/src/server/ReactDOMFizzStaticNode.js @@ -16,7 +16,7 @@ import {Writable, Readable} from 'stream'; import ReactVersion from 'shared/ReactVersion'; import { - createPrerenderRequest, + createRequest, startWork, startFlowing, abort, @@ -92,7 +92,7 @@ function prerenderToNodeStream( options ? options.bootstrapModules : undefined, options ? options.unstable_externalRuntimeSrc : undefined, ); - const request = createPrerenderRequest( + const request = createRequest( children, resumableState, createRenderState(resumableState, undefined), @@ -100,6 +100,8 @@ function prerenderToNodeStream( options ? options.progressiveChunkSize : undefined, options ? options.onError : undefined, onAllReady, + undefined, + undefined, onFatalError, options ? options.onPostpone : undefined, ); diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index 74d6777d776a6..12901e29a4021 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -281,7 +281,7 @@ function defaultErrorHandler(error: mixed) { function noop(): void {} -function createRequestImpl( +export function createRequest( children: ReactNodeList, resumableState: ResumableState, renderState: RenderState, @@ -352,86 +352,6 @@ function createRequestImpl( return request; } -export function createRequest( - children: ReactNodeList, - resumableState: ResumableState, - renderState: RenderState, - rootFormatContext: FormatContext, - progressiveChunkSize: void | number, - onError: void | ((error: mixed) => ?string), - onAllReady: void | (() => void), - onShellReady: void | (() => void), - onShellError: void | ((error: mixed) => void), - onFatalError: void | ((error: mixed) => void), - onPostpone: void | ((reason: string) => void), -): Request { - return createRequestImpl( - children, - resumableState, - renderState, - rootFormatContext, - progressiveChunkSize, - onError, - onAllReady, - onShellReady, - onShellError, - onFatalError, - onPostpone, - ); -} - -export function createPrerenderRequest( - children: ReactNodeList, - resumableState: ResumableState, - renderState: RenderState, - rootFormatContext: FormatContext, - progressiveChunkSize: void | number, - onError: void | ((error: mixed) => ?string), - onAllReady: void | (() => void), - onFatalError: void | ((error: mixed) => void), - onPostpone: void | ((reason: string) => void), -): Request { - return createRequestImpl( - children, - resumableState, - renderState, - rootFormatContext, - progressiveChunkSize, - onError, - onAllReady, - undefined, - undefined, - onFatalError, - onPostpone, - ); -} - -export function resumeRequest( - children: ReactNodeList, - postponedState: PostponedState, - renderState: RenderState, - onError: void | ((error: mixed) => ?string), - onAllReady: void | (() => void), - onShellReady: void | (() => void), - onShellError: void | ((error: mixed) => void), - onFatalError: void | ((error: mixed) => void), - onPostpone: void | ((reason: string) => void), -): Request { - return createRequestImpl( - children, - postponedState.resumableState, - renderState, - postponedState.rootFormatContext, - postponedState.progressiveChunkSize, - onError, - onAllReady, - onShellReady, - onShellError, - onFatalError, - onPostpone, - ); -} - let currentRequest: null | Request = null; export function resolveRequest(): null | Request {