MCPcopy
hub / github.com/facebook/react / getPostponedState

Function getPostponedState

packages/react-server/src/ReactFizzServer.js:6374–6415  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

6372
6373// Returns the state of a postponed request or null if nothing was postponed.
6374export function getPostponedState(request: Request): null | PostponedState {
6375 const trackedPostpones = request.trackedPostpones;
6376 if (
6377 trackedPostpones === null ||
6378 (trackedPostpones.rootNodes.length === 0 &&
6379 trackedPostpones.rootSlots === null)
6380 ) {
6381 // Reset. Let the flushing behave as if we completed the whole document.
6382 request.trackedPostpones = null;
6383 return null;
6384 }
6385 let replaySlots: ResumeSlots;
6386 let nextSegmentId: number;
6387 if (
6388 request.completedRootSegment !== null &&
6389 // The Root postponed
6390 (request.completedRootSegment.status === POSTPONED ||
6391 // Or the Preamble was not available
6392 request.completedPreambleSegments === null)
6393 ) {
6394 nextSegmentId = 0;
6395 // We need to ensure that on resume we retry the root. We use a number
6396 // type for the replaySlots to signify this (see resumeRequest).
6397 // The value -1 represents an unassigned ID but is not functionally meaningful
6398 // for resuming at the root.
6399 replaySlots = -1;
6400 // We either postponed the root or we did not have a preamble to flush
6401 resetResumableState(request.resumableState, request.renderState);
6402 } else {
6403 nextSegmentId = request.nextSegmentId;
6404 replaySlots = trackedPostpones.rootSlots;
6405 completeResumableState(request.resumableState);
6406 }
6407 return {
6408 nextSegmentId,
6409 rootFormatContext: request.rootFormatContext,
6410 progressiveChunkSize: request.progressiveChunkSize,
6411 resumableState: request.resumableState,
6412 replayNodes: trackedPostpones.rootNodes,
6413 replaySlots,
6414 };
6415}

Callers 3

onAllReadyFunction · 0.90
onAllReadyFunction · 0.90
onAllReadyFunction · 0.90

Calls 2

resetResumableStateFunction · 0.90
completeResumableStateFunction · 0.90

Tested by

no test coverage detected