Skip to content

Commit

Permalink
old
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaruan committed Jun 28, 2022
1 parent 7fd9ac6 commit ff6fa5e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberBeginWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ function updateTracingMarkerComponent(
}
}

const instance = workInProgress.stateNode;
const instance: TracingMarkerInstance = workInProgress.stateNode;
if (instance !== null) {
pushMarkerInstance(workInProgress, instance);
}
Expand Down
25 changes: 12 additions & 13 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -2819,30 +2819,25 @@ function commitPassiveMountOnFiber(
transitionName: transition.name,
startTime: transition.startTime,
});

if (!incompleteTransitions.has(transition)) {
incompleteTransitions.set(transition, null);
}
});

clearTransitionsForLanes(finishedRoot, committedLanes);
}

if (incompleteTransitions !== null) {
incompleteTransitions.forEach((pendingBoundaries, transition) => {
if (pendingBoundaries === null || pendingBoundaries.size === 0) {
incompleteTransitions.forEach(
({pendingSuspenseBoundaries}, transition) => {
if (
pendingSuspenseBoundaries === null ||
pendingSuspenseBoundaries.size === 0
) {
addTransitionCompleteCallbackToPendingTransition({
transitionName: transition.name,
startTime: transition.startTime,
});
incompleteTransitions.delete(transition);
}
});

if (incompleteTransitions.size === 0) {
root.incompleteTransitions = null;
}
}
},
);

clearTransitionsForLanes(finishedRoot, committedLanes);
}
Expand Down Expand Up @@ -2908,6 +2903,10 @@ function commitPassiveMountOnFiber(
const markerInstances = queue.markerInstances;
if (markerInstances !== null) {
markerInstances.forEach(markerInstance => {
if (markerInstance.pendingSuspenseBoundaries === null) {
markerInstance.pendingSuspenseBoundaries = new Map();
}

const markerTransitions = markerInstance.transitions;
// There should only be a few tracing marker transitions because
// they should be only associated with the transition that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,36 +117,26 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
// marker does, so we can push it onto the marker instance stack
const transitions = getWorkInProgressTransitions();
const root = workInProgress.stateNode;
let incompleteTransitions = root.incompleteTransitions;
if (transitions !== null) {
// Create a mapping from transition to suspense boundaries
// We instantiate this lazily, only if transitions exist
if (incompleteTransitions === null) {
root.incompleteTransitions = incompleteTransitions = new Map();
}

if (transitions !== null) {
transitions.forEach(transition => {
// We need to create a new map here because we only have access to the
// object instance in the commit phase
incompleteTransitions.set(transition, new Map());
if (!root.incompleteTransitions.has(transition)) {
root.incompleteTransitions.set(transition, {
transitions: new Set([transition]),
pendingSuspenseBoundaries: null,
});
}
});
}

if (incompleteTransitions === null) {
push(markerInstanceStack, null, workInProgress);
} else {
const markerInstances = [];
// For ever transition on the suspense boundary, we push the transition
// along with its map of pending suspense boundaries onto the marker
// instance stack.
incompleteTransitions.forEach((pendingSuspenseBoundaries, transition) => {
markerInstances.push({
transitions: new Set([transition]),
pendingSuspenseBoundaries,
});
});
push(markerInstanceStack, markerInstances, workInProgress);
}
const markerInstances = [];
// For ever transition on the suspense boundary, we push the transition
// along with its map of pending suspense boundaries onto the marker
// instance stack.
root.incompleteTransitions.forEach(markerInstance => {
markerInstances.push(markerInstance);
});
push(markerInstanceStack, markerInstances, workInProgress);
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,9 @@ export function popRenderLanes(fiber: Fiber) {
function prepareFreshStack(root: FiberRoot, lanes: Lanes): Fiber {
root.finishedWork = null;
root.finishedLanes = NoLanes;
if (root.incompleteTransitions === null) {
root.incompleteTransitions = new Map();
}

const timeoutHandle = root.timeoutHandle;
if (timeoutHandle !== noTimeout) {
Expand Down

0 comments on commit ff6fa5e

Please sign in to comment.