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

Function renderChildrenArray

packages/react-server/src/ReactFizzServer.js:3759–3846  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  children: Array<any>,
  childIndex: number,
)

Source from the content-addressed store, hash-verified

3757}
3758
3759function renderChildrenArray(
3760 request: Request,
3761 task: Task,
3762 children: Array<any>,
3763 childIndex: number,
3764): void {
3765 const prevKeyPath = task.keyPath;
3766 const previousComponentStack = task.componentStack;
3767 let previousDebugTask = null;
3768 if (__DEV__) {
3769 previousDebugTask = task.debugTask;
3770 // We read debugInfo from task.node instead of children because it might have been an
3771 // unwrapped iterable so we read from the original node.
3772 pushServerComponentStack(task, (task.node: any)._debugInfo);
3773 }
3774 if (childIndex !== -1) {
3775 task.keyPath = [task.keyPath, 'Fragment', childIndex];
3776 if (task.replay !== null) {
3777 replayFragment(
3778 request,
3779 // $FlowFixMe: Refined.
3780 task,
3781 children,
3782 childIndex,
3783 );
3784 task.keyPath = prevKeyPath;
3785 if (__DEV__) {
3786 task.componentStack = previousComponentStack;
3787 task.debugTask = previousDebugTask;
3788 }
3789 return;
3790 }
3791 }
3792
3793 const prevTreeContext = task.treeContext;
3794 const totalChildren = children.length;
3795
3796 if (task.replay !== null) {
3797 // Replay
3798 // First we need to check if we have any resume slots at this level.
3799 const resumeSlots = task.replay.slots;
3800 if (resumeSlots !== null && typeof resumeSlots === 'object') {
3801 for (let i = 0; i < totalChildren; i++) {
3802 const node = children[i];
3803 task.treeContext = pushTreeContext(prevTreeContext, totalChildren, i);
3804 // We need to use the non-destructive form so that we can safely pop back
3805 // up and render the sibling if something suspends.
3806 const resumeSegmentID = resumeSlots[i];
3807 // TODO: If this errors we should still continue with the next sibling.
3808 if (typeof resumeSegmentID === 'number') {
3809 resumeNode(request, task, resumeSegmentID, node, i);
3810 // We finished rendering this node, so now we can consume this
3811 // slot. This must happen after in case we rerender this task.
3812 delete resumeSlots[i];
3813 } else {
3814 renderNode(request, task, node, i);
3815 }
3816 }

Callers 2

retryNodeFunction · 0.85
replayFragmentFunction · 0.85

Calls 6

pushTreeContextFunction · 0.90
pushServerComponentStackFunction · 0.85
replayFragmentFunction · 0.85
resumeNodeFunction · 0.85
renderNodeFunction · 0.85
warnForMissingKeyFunction · 0.70

Tested by

no test coverage detected