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

Function trackPostponedBoundary

packages/react-server/src/ReactFizzServer.js:3848–3889  ·  view source on GitHub ↗
(
  request: Request,
  trackedPostpones: PostponedHoles,
  boundary: SuspenseBoundary,
)

Source from the content-addressed store, hash-verified

3846}
3847
3848function trackPostponedBoundary(
3849 request: Request,
3850 trackedPostpones: PostponedHoles,
3851 boundary: SuspenseBoundary,
3852): ReplaySuspenseBoundary {
3853 boundary.status = POSTPONED;
3854 // We need to eagerly assign it an ID because we'll need to refer to
3855 // it before flushing and we know that we can't inline it.
3856 boundary.rootSegmentID = request.nextSegmentId++;
3857
3858 const boundaryKeyPath = boundary.trackedContentKeyPath;
3859 if (boundaryKeyPath === null) {
3860 throw new Error(
3861 'It should not be possible to postpone at the root. This is a bug in React.',
3862 );
3863 }
3864
3865 const fallbackReplayNode = boundary.trackedFallbackNode;
3866
3867 const children: Array<ReplayNode> = [];
3868 const boundaryNode: void | ReplayNode =
3869 trackedPostpones.workingMap.get(boundaryKeyPath);
3870 if (boundaryNode === undefined) {
3871 const suspenseBoundary: ReplaySuspenseBoundary = [
3872 boundaryKeyPath[1],
3873 boundaryKeyPath[2],
3874 children,
3875 null,
3876 fallbackReplayNode,
3877 boundary.rootSegmentID,
3878 ];
3879 trackedPostpones.workingMap.set(boundaryKeyPath, suspenseBoundary);
3880 addToReplayParent(suspenseBoundary, boundaryKeyPath[0], trackedPostpones);
3881 return suspenseBoundary;
3882 } else {
3883 // Upgrade to ReplaySuspenseBoundary.
3884 const suspenseBoundary: ReplaySuspenseBoundary = (boundaryNode: any);
3885 suspenseBoundary[4] = fallbackReplayNode;
3886 suspenseBoundary[5] = boundary.rootSegmentID;
3887 return suspenseBoundary;
3888 }
3889}
3890
3891function trackPostpone(
3892 request: Request,

Callers 2

trackPostponeFunction · 0.85

Calls 3

addToReplayParentFunction · 0.85
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected