From 8562316225fef71cad7285526fab22327fd37f1a Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Fri, 29 Sep 2023 16:00:30 -0400 Subject: [PATCH] We can simplify checks that are now done deeper --- packages/react-server/src/ReactFizzServer.js | 73 ++++++-------------- 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index a7e161d5b3119..951b3e07930a2 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -1019,11 +1019,7 @@ function replaySuspenseBoundary( } try { // We use the safe form because we don't handle suspending here. Only error handling. - if (typeof childSlots === 'number') { - resumeNode(request, task, childSlots, content, -1); - } else { - renderNode(request, task, content, -1); - } + renderNode(request, task, content, -1); if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0) { throw new Error( "Couldn't find all resumable slots by key/index during replaying. " + @@ -1086,56 +1082,27 @@ function replaySuspenseBoundary( const fallbackKeyPath = [keyPath[0], 'Suspense Fallback', keyPath[2]]; - let suspendedFallbackTask; // We create suspended task for the fallback because we don't want to actually work // on it yet in case we finish the main content, so we queue for later. - if (typeof fallbackSlots === 'number') { - // Resuming directly in the fallback. - const resumedSegment = createPendingSegment( - request, - 0, - null, - task.formatContext, - false, - false, - ); - resumedSegment.id = fallbackSlots; - resumedSegment.parentFlushed = true; - suspendedFallbackTask = createRenderTask( - request, - null, - fallback, - -1, - parentBoundary, - resumedSegment, - fallbackAbortSet, - fallbackKeyPath, - task.formatContext, - task.legacyContext, - task.context, - task.treeContext, - ); - } else { - const fallbackReplay = { - nodes: fallbackNodes, - slots: fallbackSlots, - pendingTasks: 0, - }; - suspendedFallbackTask = createReplayTask( - request, - null, - fallbackReplay, - fallback, - -1, - parentBoundary, - fallbackAbortSet, - fallbackKeyPath, - task.formatContext, - task.legacyContext, - task.context, - task.treeContext, - ); - } + const fallbackReplay = { + nodes: fallbackNodes, + slots: fallbackSlots, + pendingTasks: 0, + }; + const suspendedFallbackTask = createReplayTask( + request, + null, + fallbackReplay, + fallback, + -1, + parentBoundary, + fallbackAbortSet, + fallbackKeyPath, + task.formatContext, + task.legacyContext, + task.context, + task.treeContext, + ); if (__DEV__) { suspendedFallbackTask.componentStack = task.componentStack; }