Skip to content

Commit 8e35b50

Browse files
authored
[Transition Tracing] Refactor Code to Remove OffscreeInstance TODOs (#24855)
Refactored code to pass flow and remove TODOs introduced in #24846
1 parent deab126 commit 8e35b50

File tree

2 files changed

+28
-60
lines changed

2 files changed

+28
-60
lines changed

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

+14-30
Original file line numberDiff line numberDiff line change
@@ -2923,56 +2923,40 @@ function commitPassiveMountOnFiber(
29232923
if (queue !== null) {
29242924
if (isFallback) {
29252925
const transitions = queue.transitions;
2926-
let prevTransitions = instance.transitions;
2927-
if (instance.pendingMarkers === null) {
2928-
instance.pendingMarkers = new Set();
2929-
}
2930-
if (transitions !== null && prevTransitions === null) {
2931-
instance.transitions = prevTransitions = new Set();
2932-
}
2933-
29342926
if (transitions !== null) {
29352927
transitions.forEach(transition => {
29362928
// Add all the transitions saved in the update queue during
29372929
// the render phase (ie the transitions associated with this boundary)
29382930
// into the transitions set.
2939-
if (prevTransitions === null) {
2940-
// TODO: What if prevTransitions is null?
2941-
} else {
2942-
prevTransitions.add(transition);
2931+
if (instance.transitions === null) {
2932+
instance.transitions = new Set();
29432933
}
2934+
instance.transitions.add(transition);
29442935
});
29452936
}
29462937

29472938
const markerInstances = queue.markerInstances;
29482939
if (markerInstances !== null) {
29492940
markerInstances.forEach(markerInstance => {
2950-
if (markerInstance.pendingSuspenseBoundaries === null) {
2951-
markerInstance.pendingSuspenseBoundaries = new Map();
2952-
}
2953-
29542941
const markerTransitions = markerInstance.transitions;
29552942
// There should only be a few tracing marker transitions because
29562943
// they should be only associated with the transition that
29572944
// caused them
29582945
if (markerTransitions !== null) {
29592946
markerTransitions.forEach(transition => {
29602947
if (instance.transitions === null) {
2961-
// TODO: What if instance.transitions is null?
2962-
} else {
2963-
if (instance.transitions.has(transition)) {
2964-
if (
2965-
instance.pendingMarkers === null ||
2966-
markerInstance.pendingSuspenseBoundaries === null
2967-
) {
2968-
// TODO: What if instance.pendingMarkers is null?
2969-
// TODO: What if markerInstance.pendingSuspenseBoundaries is null?
2970-
} else {
2971-
instance.pendingMarkers.add(
2972-
markerInstance.pendingSuspenseBoundaries,
2973-
);
2974-
}
2948+
instance.transitions = new Set();
2949+
} else if (instance.transitions.has(transition)) {
2950+
if (markerInstance.pendingSuspenseBoundaries === null) {
2951+
markerInstance.pendingSuspenseBoundaries = new Map();
2952+
}
2953+
if (instance.pendingMarkers === null) {
2954+
instance.pendingMarkers = new Set();
29752955
}
2956+
2957+
instance.pendingMarkers.add(
2958+
markerInstance.pendingSuspenseBoundaries,
2959+
);
29762960
}
29772961
});
29782962
}

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

+14-30
Original file line numberDiff line numberDiff line change
@@ -2878,56 +2878,40 @@ function commitPassiveMountOnFiber(
28782878
if (queue !== null) {
28792879
if (isFallback) {
28802880
const transitions = queue.transitions;
2881-
let prevTransitions = instance.transitions;
2882-
if (instance.pendingMarkers === null) {
2883-
instance.pendingMarkers = new Set();
2884-
}
2885-
if (transitions !== null && prevTransitions === null) {
2886-
instance.transitions = prevTransitions = new Set();
2887-
}
2888-
28892881
if (transitions !== null) {
28902882
transitions.forEach(transition => {
28912883
// Add all the transitions saved in the update queue during
28922884
// the render phase (ie the transitions associated with this boundary)
28932885
// into the transitions set.
2894-
if (prevTransitions === null) {
2895-
// TODO: What if prevTransitions is null?
2896-
} else {
2897-
prevTransitions.add(transition);
2886+
if (instance.transitions === null) {
2887+
instance.transitions = new Set();
28982888
}
2889+
instance.transitions.add(transition);
28992890
});
29002891
}
29012892

29022893
const markerInstances = queue.markerInstances;
29032894
if (markerInstances !== null) {
29042895
markerInstances.forEach(markerInstance => {
2905-
if (markerInstance.pendingSuspenseBoundaries === null) {
2906-
markerInstance.pendingSuspenseBoundaries = new Map();
2907-
}
2908-
29092896
const markerTransitions = markerInstance.transitions;
29102897
// There should only be a few tracing marker transitions because
29112898
// they should be only associated with the transition that
29122899
// caused them
29132900
if (markerTransitions !== null) {
29142901
markerTransitions.forEach(transition => {
29152902
if (instance.transitions === null) {
2916-
// TODO: What if instance.transitions is null?
2917-
} else {
2918-
if (instance.transitions.has(transition)) {
2919-
if (
2920-
instance.pendingMarkers === null ||
2921-
markerInstance.pendingSuspenseBoundaries === null
2922-
) {
2923-
// TODO: What if instance.pendingMarkers is null?
2924-
// TODO: What if markerInstance.pendingSuspenseBoundaries is null?
2925-
} else {
2926-
instance.pendingMarkers.add(
2927-
markerInstance.pendingSuspenseBoundaries,
2928-
);
2929-
}
2903+
instance.transitions = new Set();
2904+
} else if (instance.transitions.has(transition)) {
2905+
if (markerInstance.pendingSuspenseBoundaries === null) {
2906+
markerInstance.pendingSuspenseBoundaries = new Map();
2907+
}
2908+
if (instance.pendingMarkers === null) {
2909+
instance.pendingMarkers = new Set();
29302910
}
2911+
2912+
instance.pendingMarkers.add(
2913+
markerInstance.pendingSuspenseBoundaries,
2914+
);
29312915
}
29322916
});
29332917
}

0 commit comments

Comments
 (0)