Skip to content

Commit a320d29

Browse files
committed
old
1 parent 03995a2 commit a320d29

6 files changed

Lines changed: 42 additions & 44 deletions

packages/react-reconciler/src/ReactFiberBeginWork.old.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import type {
2727
OffscreenProps,
2828
OffscreenState,
2929
OffscreenQueue,
30+
OffscreenInstance,
3031
} from './ReactFiberOffscreenComponent';
3132
import type {
3233
Cache,
@@ -785,7 +786,10 @@ function updateOffscreenComponent(
785786
if (enableTransitionTracing) {
786787
// We have now gone from hidden to visible, so any transitions should
787788
// be added to the stack to get added to any Offscreen/suspense children
788-
transitions = workInProgress.stateNode.transitions;
789+
const instance: OffscreenInstance | null = workInProgress.stateNode;
790+
if (instance !== null && instance.transitions !== null) {
791+
transitions = Array.from(instance.transitions);
792+
}
789793
}
790794

791795
pushTransition(workInProgress, prevCachePool, transitions);
@@ -910,7 +914,7 @@ function updateTracingMarkerComponent(
910914
}
911915
}
912916

913-
const instance = workInProgress.stateNode;
917+
const instance: TracingMarkerInstance | null = workInProgress.stateNode;
914918
if (instance !== null) {
915919
pushMarkerInstance(workInProgress, instance);
916920
}
@@ -3714,7 +3718,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
37143718
}
37153719
case TracingMarkerComponent: {
37163720
if (enableTransitionTracing) {
3717-
const instance: TracingMarkerInstance = workInProgress.stateNode;
3721+
const instance: TracingMarkerInstance | null = workInProgress.stateNode;
37183722
if (instance !== null) {
37193723
pushMarkerInstance(workInProgress, instance);
37203724
}

packages/react-reconciler/src/ReactFiberCommitWork.old.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,30 +2819,25 @@ function commitPassiveMountOnFiber(
28192819
transitionName: transition.name,
28202820
startTime: transition.startTime,
28212821
});
2822-
2823-
if (!incompleteTransitions.has(transition)) {
2824-
incompleteTransitions.set(transition, null);
2825-
}
28262822
});
28272823

28282824
clearTransitionsForLanes(finishedRoot, committedLanes);
28292825
}
28302826

2831-
if (incompleteTransitions !== null) {
2832-
incompleteTransitions.forEach((pendingBoundaries, transition) => {
2833-
if (pendingBoundaries === null || pendingBoundaries.size === 0) {
2827+
incompleteTransitions.forEach(
2828+
({pendingSuspenseBoundaries}, transition) => {
2829+
if (
2830+
pendingSuspenseBoundaries === null ||
2831+
pendingSuspenseBoundaries.size === 0
2832+
) {
28342833
addTransitionCompleteCallbackToPendingTransition({
28352834
transitionName: transition.name,
28362835
startTime: transition.startTime,
28372836
});
28382837
incompleteTransitions.delete(transition);
28392838
}
2840-
});
2841-
2842-
if (incompleteTransitions.size === 0) {
2843-
root.incompleteTransitions = null;
2844-
}
2845-
}
2839+
},
2840+
);
28462841

28472842
clearTransitionsForLanes(finishedRoot, committedLanes);
28482843
}
@@ -2908,6 +2903,10 @@ function commitPassiveMountOnFiber(
29082903
const markerInstances = queue.markerInstances;
29092904
if (markerInstances !== null) {
29102905
markerInstances.forEach(markerInstance => {
2906+
if (markerInstance.pendingSuspenseBoundaries === null) {
2907+
markerInstance.pendingSuspenseBoundaries = new Map();
2908+
}
2909+
29112910
const markerTransitions = markerInstance.transitions;
29122911
// There should only be a few tracing marker transitions because
29132912
// they should be only associated with the transition that

packages/react-reconciler/src/ReactFiberCompleteWork.old.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type {
2929
} from './ReactFiberSuspenseComponent.old';
3030
import type {SuspenseContext} from './ReactFiberSuspenseContext.old';
3131
import type {OffscreenState} from './ReactFiberOffscreenComponent';
32+
import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent.old';
3233
import type {Cache} from './ReactFiberCacheComponent.old';
3334
import {
3435
enableSuspenseAvoidThisFallback,
@@ -1589,7 +1590,8 @@ function completeWork(
15891590
}
15901591
case TracingMarkerComponent: {
15911592
if (enableTransitionTracing) {
1592-
if (workInProgress.stateNode !== null) {
1593+
const instance: TracingMarkerInstance | null = workInProgress.stateNode;
1594+
if (instance !== null) {
15931595
popMarkerInstance(workInProgress);
15941596
}
15951597
bubbleProperties(workInProgress);

packages/react-reconciler/src/ReactFiberRoot.old.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function FiberRootNode(
9696
for (let i = 0; i < TotalLanes; i++) {
9797
transitionLanesMap.push(null);
9898
}
99-
this.incompleteTransitions = null;
99+
this.incompleteTransitions = new Map();
100100
}
101101

102102
if (enableProfilerTimer && enableProfilerCommitHooks) {

packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,36 +117,26 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
117117
// marker does, so we can push it onto the marker instance stack
118118
const transitions = getWorkInProgressTransitions();
119119
const root = workInProgress.stateNode;
120-
let incompleteTransitions = root.incompleteTransitions;
121-
if (transitions !== null) {
122-
// Create a mapping from transition to suspense boundaries
123-
// We instantiate this lazily, only if transitions exist
124-
if (incompleteTransitions === null) {
125-
root.incompleteTransitions = incompleteTransitions = new Map();
126-
}
127120

121+
if (transitions !== null) {
128122
transitions.forEach(transition => {
129-
// We need to create a new map here because we only have access to the
130-
// object instance in the commit phase
131-
incompleteTransitions.set(transition, new Map());
123+
if (!root.incompleteTransitions.has(transition)) {
124+
root.incompleteTransitions.set(transition, {
125+
transitions: new Set([transition]),
126+
pendingSuspenseBoundaries: null,
127+
});
128+
}
132129
});
133130
}
134131

135-
if (incompleteTransitions === null) {
136-
push(markerInstanceStack, null, workInProgress);
137-
} else {
138-
const markerInstances = [];
139-
// For ever transition on the suspense boundary, we push the transition
140-
// along with its map of pending suspense boundaries onto the marker
141-
// instance stack.
142-
incompleteTransitions.forEach((pendingSuspenseBoundaries, transition) => {
143-
markerInstances.push({
144-
transitions: new Set([transition]),
145-
pendingSuspenseBoundaries,
146-
});
147-
});
148-
push(markerInstanceStack, markerInstances, workInProgress);
149-
}
132+
const markerInstances = [];
133+
// For ever transition on the suspense boundary, we push the transition
134+
// along with its map of pending suspense boundaries onto the marker
135+
// instance stack.
136+
root.incompleteTransitions.forEach(markerInstance => {
137+
markerInstances.push(markerInstance);
138+
});
139+
push(markerInstanceStack, markerInstances, workInProgress);
150140
}
151141
}
152142

packages/react-reconciler/src/ReactFiberUnwindWork.old.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {Fiber, FiberRoot} from './ReactInternalTypes';
1212
import type {Lanes} from './ReactFiberLane.old';
1313
import type {SuspenseState} from './ReactFiberSuspenseComponent.old';
1414
import type {Cache} from './ReactFiberCacheComponent.old';
15+
import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent.old';
1516

1617
import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.old';
1718
import {
@@ -245,7 +246,9 @@ function unwindInterruptedWork(
245246
break;
246247
case TracingMarkerComponent:
247248
if (enableTransitionTracing) {
248-
if (interruptedWork.stateNode !== null) {
249+
const instance: TracingMarkerInstance | null =
250+
interruptedWork.stateNode;
251+
if (instance !== null) {
249252
popMarkerInstance(interruptedWork);
250253
}
251254
}

0 commit comments

Comments
 (0)