Skip to content

Commit 8794cba

Browse files
committed
[do not merge] Temporary keyPath fixes
Found some keyPath bugs. Seb is fixing one of them in another PR. Patching them here to unblock testing the fixture.
1 parent 2f03649 commit 8794cba

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

packages/react-server/src/ReactFizzServer.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export type Task = {
218218
blockedSegment: Segment, // the segment we'll write to
219219
abortSet: Set<Task>, // the abortable set that this task belongs to
220220
keyPath: Root | KeyNode, // the path of all parent keys currently rendering
221+
index: number,
221222
formatContext: FormatContext, // the format's specific context (e.g. HTML/SVG/MathML)
222223
legacyContext: LegacyContext, // the current legacy context that this task is executing in
223224
context: ContextSnapshot, // the current new context that this task is executing in
@@ -388,6 +389,7 @@ export function createRequest(
388389
rootSegment,
389390
abortSet,
390391
null,
392+
0,
391393
rootFormatContext,
392394
emptyContextObject,
393395
rootContextSnapshot,
@@ -489,6 +491,7 @@ export function resumeRequest(
489491
rootSegment,
490492
abortSet,
491493
null,
494+
0,
492495
postponedState.rootFormatContext,
493496
emptyContextObject,
494497
rootContextSnapshot,
@@ -546,6 +549,7 @@ function createTask(
546549
blockedSegment: Segment,
547550
abortSet: Set<Task>,
548551
keyPath: Root | KeyNode,
552+
index: number,
549553
formatContext: FormatContext,
550554
legacyContext: LegacyContext,
551555
context: ContextSnapshot,
@@ -564,6 +568,7 @@ function createTask(
564568
blockedSegment,
565569
abortSet,
566570
keyPath,
571+
index,
567572
formatContext,
568573
legacyContext,
569574
context,
@@ -845,6 +850,7 @@ function renderSuspenseBoundary(
845850
boundarySegment,
846851
fallbackAbortSet,
847852
task.keyPath,
853+
1,
848854
task.formatContext,
849855
task.legacyContext,
850856
task.context,
@@ -968,7 +974,7 @@ function finishClassComponent(
968974
childContextTypes,
969975
);
970976
task.legacyContext = mergedContext;
971-
renderNodeDestructive(request, task, null, nextChildren, 0);
977+
renderNode(request, task, nextChildren, 0);
972978
task.legacyContext = previousContext;
973979
return;
974980
}
@@ -1907,6 +1913,7 @@ function injectPostponedHole(
19071913
function spawnNewSuspendedTask(
19081914
request: Request,
19091915
task: Task,
1916+
childIndex: number,
19101917
thenableState: ThenableState | null,
19111918
x: Wakeable,
19121919
): void {
@@ -1934,6 +1941,7 @@ function spawnNewSuspendedTask(
19341941
newSegment,
19351942
task.abortSet,
19361943
task.keyPath,
1944+
childIndex,
19371945
task.formatContext,
19381946
task.legacyContext,
19391947
task.context,
@@ -1998,17 +2006,24 @@ function renderNode(
19982006
if (typeof x === 'object' && x !== null) {
19992007
// $FlowFixMe[method-unbinding]
20002008
if (typeof x.then === 'function') {
2001-
const wakeable: Wakeable = (x: any);
2002-
const thenableState = getThenableStateAfterSuspending();
2003-
spawnNewSuspendedTask(request, task, thenableState, wakeable);
2004-
20052009
// Restore the context. We assume that this will be restored by the inner
20062010
// functions in case nothing throws so we don't use "finally" here.
20072011
task.formatContext = previousFormatContext;
20082012
task.legacyContext = previousLegacyContext;
20092013
task.context = previousContext;
20102014
task.keyPath = previousKeyPath;
20112015
task.treeContext = previousTreeContext;
2016+
2017+
const wakeable: Wakeable = (x: any);
2018+
const thenableState = getThenableStateAfterSuspending();
2019+
spawnNewSuspendedTask(
2020+
request,
2021+
task,
2022+
childIndex,
2023+
thenableState,
2024+
wakeable,
2025+
);
2026+
20122027
// Restore all active ReactContexts to what they were before.
20132028
switchContext(previousContext);
20142029
if (__DEV__) {
@@ -2336,7 +2351,13 @@ function retryTask(request: Request, task: Task): void {
23362351
const prevThenableState = task.thenableState;
23372352
task.thenableState = null;
23382353

2339-
renderNodeDestructive(request, task, prevThenableState, task.node, 0);
2354+
renderNodeDestructive(
2355+
request,
2356+
task,
2357+
prevThenableState,
2358+
task.node,
2359+
task.index,
2360+
);
23402361
pushSegmentFinale(
23412362
segment.chunks,
23422363
request.renderState,

0 commit comments

Comments
 (0)