Skip to content

Commit

Permalink
We can simplify checks that are now done deeper
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Sep 29, 2023
1 parent 7bbdb7a commit 7acd0ac
Showing 1 changed file with 20 additions and 52 deletions.
72 changes: 20 additions & 52 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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. " +
Expand Down Expand Up @@ -1089,53 +1085,25 @@ function replaySuspenseBoundary(
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,
};
suspendedFallbackTask = createReplayTask(
request,
null,
fallbackReplay,
fallback,
-1,
parentBoundary,
fallbackAbortSet,
fallbackKeyPath,
task.formatContext,
task.legacyContext,
task.context,
task.treeContext,
);
if (__DEV__) {
suspendedFallbackTask.componentStack = task.componentStack;
}
Expand Down

0 comments on commit 7acd0ac

Please sign in to comment.