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

Function flushSegment

packages/react-server/src/ReactFizzServer.js:5672–5820  ·  view source on GitHub ↗
(
  request: Request,
  destination: Destination,
  segment: Segment,
  hoistableState: null | HoistableState,
)

Source from the content-addressed store, hash-verified

5670let flushedByteSize = 0;
5671
5672function flushSegment(
5673 request: Request,
5674 destination: Destination,
5675 segment: Segment,
5676 hoistableState: null | HoistableState,
5677): boolean {
5678 const boundary = segment.boundary;
5679 if (boundary === null) {
5680 // Not a suspense boundary.
5681 return flushSubtree(request, destination, segment, hoistableState);
5682 }
5683
5684 boundary.parentFlushed = true;
5685 // This segment is a Suspense boundary. We need to decide whether to
5686 // emit the content or the fallback now.
5687 if (boundary.status === CLIENT_RENDERED) {
5688 // Emit a client rendered suspense boundary wrapper.
5689 // We never queue the inner boundary so we'll never emit its content or partial segments.
5690
5691 const row = boundary.row;
5692 if (row !== null) {
5693 // Since this boundary end up client rendered, we can unblock future suspense list rows.
5694 // This means that they may appear out of order if the future rows succeed but this is
5695 // a client rendered row.
5696 if (--row.pendingTasks === 0) {
5697 finishSuspenseListRow(request, row);
5698 }
5699 }
5700
5701 if (__DEV__) {
5702 writeStartClientRenderedSuspenseBoundary(
5703 destination,
5704 request.renderState,
5705 boundary.errorDigest,
5706 boundary.errorMessage,
5707 boundary.errorStack,
5708 boundary.errorComponentStack,
5709 );
5710 } else {
5711 writeStartClientRenderedSuspenseBoundary(
5712 destination,
5713 request.renderState,
5714 boundary.errorDigest,
5715 null,
5716 null,
5717 null,
5718 );
5719 }
5720 // Flush the fallback.
5721 flushSubtree(request, destination, segment, hoistableState);
5722
5723 return writeEndClientRenderedSuspenseBoundary(
5724 destination,
5725 request.renderState,
5726 );
5727 } else if (boundary.status !== COMPLETED) {
5728 if (boundary.status === PENDING) {
5729 // For pending boundaries we lazily assign an ID to the boundary

Callers 4

flushPreambleFunction · 0.85
flushSubtreeFunction · 0.85
flushSegmentContainerFunction · 0.85
flushCompletedQueuesFunction · 0.85

Tested by

no test coverage detected