Skip to content

Commit 792ca6b

Browse files
committed
old
1 parent 23cb59a commit 792ca6b

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -912,11 +912,7 @@ function updateTracingMarkerComponent(
912912

913913
const instance = workInProgress.stateNode;
914914
if (instance !== null) {
915-
pushMarkerInstance(
916-
workInProgress,
917-
instance.transitions,
918-
instance.pendingSuspenseBoundaries,
919-
);
915+
pushMarkerInstance(workInProgress, instance);
920916
}
921917
const nextChildren = workInProgress.pendingProps.children;
922918
reconcileChildren(current, workInProgress, nextChildren, renderLanes);
@@ -3720,11 +3716,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
37203716
if (enableTransitionTracing) {
37213717
const instance: TracingMarkerInstance = workInProgress.stateNode;
37223718
if (instance !== null) {
3723-
pushMarkerInstance(
3724-
workInProgress,
3725-
instance.transitions,
3726-
instance.pendingSuspenseBoundaries,
3727-
);
3719+
pushMarkerInstance(workInProgress, instance);
37283720
}
37293721
}
37303722
}

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,27 @@ const markerInstanceStack: StackCursor<Array<TracingMarkerInstance> | null> = cr
107107

108108
export function pushRootMarkerInstance(workInProgress: Fiber): void {
109109
if (enableTransitionTracing) {
110+
// On the root, every transition gets mapped to it's own map of
111+
// suspense boundaries. The transition is marked as complete when
112+
// the suspense boundaries map is empty. We do this because every
113+
// transition completes at different times and depends on different
114+
// suspense boundaries to complete. We store all the transitions
115+
// along with its map of suspense boundaries in the root incomplete
116+
// transitions map. Each entry in this map functions like a tracing
117+
// marker does, so we can push it onto the marker instance stack
110118
const transitions = getWorkInProgressTransitions();
111119
const root = workInProgress.stateNode;
112120
let incompleteTransitions = root.incompleteTransitions;
113121
if (transitions !== null) {
122+
// Create a mapping from transition to suspense boundaries
123+
// We instantiate this lazily, only if transitions exist
114124
if (incompleteTransitions === null) {
115125
root.incompleteTransitions = incompleteTransitions = new Map();
116126
}
117127

118128
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
119131
incompleteTransitions.set(transition, new Map());
120132
});
121133
}
@@ -124,6 +136,9 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
124136
push(markerInstanceStack, null, workInProgress);
125137
} else {
126138
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.
127142
incompleteTransitions.forEach((pendingSuspenseBoundaries, transition) => {
128143
markerInstances.push({
129144
transitions: new Set([transition]),
@@ -143,12 +158,9 @@ export function popRootMarkerInstance(workInProgress: Fiber) {
143158

144159
export function pushMarkerInstance(
145160
workInProgress: Fiber,
146-
transitions: Set<Transition> | null,
147-
pendingSuspenseBoundaries: PendingSuspenseBoundaries | null,
161+
markerInstance: TracingMarkerInstance,
148162
): void {
149163
if (enableTransitionTracing) {
150-
const markerInstance = {transitions, pendingSuspenseBoundaries};
151-
152164
if (markerInstanceStack.current === null) {
153165
push(markerInstanceStack, [markerInstance], workInProgress);
154166
} else {

0 commit comments

Comments
 (0)