Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Transition Tracing] Refactor Code to Remove OffscreeInstance TODOs #24855

Merged
merged 2 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 14 additions & 30 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -2884,56 +2884,40 @@ function commitPassiveMountOnFiber(
if (queue !== null) {
if (isFallback) {
const transitions = queue.transitions;
let prevTransitions = instance.transitions;
if (instance.pendingMarkers === null) {
instance.pendingMarkers = new Set();
}
if (transitions !== null && prevTransitions === null) {
instance.transitions = prevTransitions = new Set();
}

if (transitions !== null) {
transitions.forEach(transition => {
// Add all the transitions saved in the update queue during
// the render phase (ie the transitions associated with this boundary)
// into the transitions set.
if (prevTransitions === null) {
// TODO: What if prevTransitions is null?
} else {
prevTransitions.add(transition);
if (instance.transitions === null) {
instance.transitions = new Set();
}
instance.transitions.add(transition);
});
}

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
// caused them
if (markerTransitions !== null) {
markerTransitions.forEach(transition => {
if (instance.transitions === null) {
// TODO: What if instance.transitions is null?
} else {
if (instance.transitions.has(transition)) {
if (
instance.pendingMarkers === null ||
markerInstance.pendingSuspenseBoundaries === null
) {
// TODO: What if instance.pendingMarkers is null?
// TODO: What if markerInstance.pendingSuspenseBoundaries is null?
} else {
instance.pendingMarkers.add(
markerInstance.pendingSuspenseBoundaries,
);
}
instance.transitions = new Set();
} else if (instance.transitions.has(transition)) {
if (markerInstance.pendingSuspenseBoundaries === null) {
markerInstance.pendingSuspenseBoundaries = new Map();
}
if (instance.pendingMarkers === null) {
instance.pendingMarkers = new Set();
}

instance.pendingMarkers.add(
markerInstance.pendingSuspenseBoundaries,
);
}
});
}
Expand Down
44 changes: 14 additions & 30 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -2884,56 +2884,40 @@ function commitPassiveMountOnFiber(
if (queue !== null) {
if (isFallback) {
const transitions = queue.transitions;
let prevTransitions = instance.transitions;
if (instance.pendingMarkers === null) {
instance.pendingMarkers = new Set();
}
if (transitions !== null && prevTransitions === null) {
instance.transitions = prevTransitions = new Set();
}

if (transitions !== null) {
transitions.forEach(transition => {
// Add all the transitions saved in the update queue during
// the render phase (ie the transitions associated with this boundary)
// into the transitions set.
if (prevTransitions === null) {
// TODO: What if prevTransitions is null?
} else {
prevTransitions.add(transition);
if (instance.transitions === null) {
instance.transitions = new Set();
}
instance.transitions.add(transition);
});
}

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
// caused them
if (markerTransitions !== null) {
markerTransitions.forEach(transition => {
if (instance.transitions === null) {
// TODO: What if instance.transitions is null?
} else {
if (instance.transitions.has(transition)) {
if (
instance.pendingMarkers === null ||
markerInstance.pendingSuspenseBoundaries === null
) {
// TODO: What if instance.pendingMarkers is null?
// TODO: What if markerInstance.pendingSuspenseBoundaries is null?
} else {
instance.pendingMarkers.add(
markerInstance.pendingSuspenseBoundaries,
);
}
instance.transitions = new Set();
} else if (instance.transitions.has(transition)) {
if (markerInstance.pendingSuspenseBoundaries === null) {
markerInstance.pendingSuspenseBoundaries = new Map();
}
if (instance.pendingMarkers === null) {
instance.pendingMarkers = new Set();
}

instance.pendingMarkers.add(
markerInstance.pendingSuspenseBoundaries,
);
}
});
}
Expand Down