Skip to content

Commit

Permalink
old
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaruan committed Jun 29, 2022
1 parent 7fd9ac6 commit 6975b0b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 43 deletions.
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -3714,7 +3714,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
}
case TracingMarkerComponent: {
if (enableTransitionTracing) {
const instance: TracingMarkerInstance = workInProgress.stateNode;
const instance: TracingMarkerInstance | null = 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
4 changes: 3 additions & 1 deletion packages/react-reconciler/src/ReactFiberCompleteWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type {
import type {SuspenseContext} from './ReactFiberSuspenseContext.old';
import type {OffscreenState} from './ReactFiberOffscreenComponent';
import type {Cache} from './ReactFiberCacheComponent.old';
import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent.old';
import {
enableSuspenseAvoidThisFallback,
enableLegacyHidden,
Expand Down Expand Up @@ -1589,7 +1590,8 @@ function completeWork(
}
case TracingMarkerComponent: {
if (enableTransitionTracing) {
if (workInProgress.stateNode !== null) {
const instance: TracingMarkerInstance | null = workInProgress.stateNode;
if (instance !== null) {
popMarkerInstance(workInProgress);
}
bubbleProperties(workInProgress);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberRoot.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function FiberRootNode(
for (let i = 0; i < TotalLanes; i++) {
transitionLanesMap.push(null);
}
this.incompleteTransitions = null;
this.incompleteTransitions = new Map();
}

if (enableProfilerTimer && enableProfilerCommitHooks) {
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
4 changes: 3 additions & 1 deletion packages/react-reconciler/src/ReactFiberUnwindWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {Fiber, FiberRoot} from './ReactInternalTypes';
import type {Lanes} from './ReactFiberLane.old';
import type {SuspenseState} from './ReactFiberSuspenseComponent.old';
import type {Cache} from './ReactFiberCacheComponent.old';
import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent.old';

import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.old';
import {
Expand Down Expand Up @@ -170,7 +171,8 @@ function unwindWork(
return null;
case TracingMarkerComponent:
if (enableTransitionTracing) {
if (workInProgress.stateNode !== null) {
const instance: TracingMarkerInstance | null = workInProgress.stateNode;
if (instance !== null) {
popMarkerInstance(workInProgress);
}
}
Expand Down

0 comments on commit 6975b0b

Please sign in to comment.