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

Function trackPostpone

packages/react-server/src/ReactFizzServer.js:3891–4006  ·  view source on GitHub ↗
(
  request: Request,
  trackedPostpones: PostponedHoles,
  task: Task,
  segment: Segment,
)

Source from the content-addressed store, hash-verified

3889}
3890
3891function trackPostpone(
3892 request: Request,
3893 trackedPostpones: PostponedHoles,
3894 task: Task,
3895 segment: Segment,
3896): void {
3897 segment.status = POSTPONED;
3898
3899 const keyPath = task.keyPath;
3900 const boundary = task.blockedBoundary;
3901
3902 if (boundary === null) {
3903 segment.id = request.nextSegmentId++;
3904 trackedPostpones.rootSlots = segment.id;
3905 if (request.completedRootSegment !== null) {
3906 // Postpone the root if this was a deeper segment.
3907 request.completedRootSegment.status = POSTPONED;
3908 }
3909 return;
3910 }
3911
3912 if (boundary !== null && boundary.status === PENDING) {
3913 const boundaryNode = trackPostponedBoundary(
3914 request,
3915 trackedPostpones,
3916 boundary,
3917 );
3918 if (boundary.trackedContentKeyPath === keyPath && task.childIndex === -1) {
3919 // Assign ID
3920 if (segment.id === -1) {
3921 if (segment.parentFlushed) {
3922 // If this segment's parent was already flushed, it means we really just
3923 // skipped the parent and this segment is now the root.
3924 segment.id = boundary.rootSegmentID;
3925 } else {
3926 segment.id = request.nextSegmentId++;
3927 }
3928 }
3929 // We postponed directly inside the Suspense boundary so we mark this for resuming.
3930 boundaryNode[3] = segment.id;
3931 return;
3932 }
3933 // Otherwise, fall through to add the child node.
3934 }
3935
3936 // We know that this will leave a hole so we might as well assign an ID now.
3937 // We might have one already if we had a parent that gave us its ID.
3938 if (segment.id === -1) {
3939 if (segment.parentFlushed && boundary !== null) {
3940 // If this segment's parent was already flushed, it means we really just
3941 // skipped the parent and this segment is now the root.
3942 segment.id = boundary.rootSegmentID;
3943 } else {
3944 segment.id = request.nextSegmentId++;
3945 }
3946 }
3947
3948 if (task.childIndex === -1) {

Callers 3

renderNodeFunction · 0.85
abortTaskFunction · 0.85
retryRenderTaskFunction · 0.85

Calls 4

trackPostponedBoundaryFunction · 0.85
addToReplayParentFunction · 0.85
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected