diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index 30709cffa5061..3d6d9cde8b291 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -25,6 +25,7 @@ import type {Wakeable} from 'shared/ReactTypes'; import type { OffscreenState, OffscreenInstance, + OffscreenQueue, } from './ReactFiberOffscreenComponent'; import type {HookFlags} from './ReactHookEffectTags'; import type {Cache} from './ReactFiberCacheComponent.new'; @@ -2877,8 +2878,8 @@ function commitPassiveMountOnFiber( if (enableTransitionTracing) { const isFallback = finishedWork.memoizedState; - const queue = (finishedWork.updateQueue: any); - const instance = finishedWork.stateNode; + const queue: OffscreenQueue = (finishedWork.updateQueue: any); + const instance: OffscreenInstance = finishedWork.stateNode; if (queue !== null) { if (isFallback) { @@ -2896,7 +2897,11 @@ function commitPassiveMountOnFiber( // Add all the transitions saved in the update queue during // the render phase (ie the transitions associated with this boundary) // into the transitions set. - prevTransitions.add(transition); + if (prevTransitions === null) { + // TODO: What if prevTransitions is null? + } else { + prevTransitions.add(transition); + } }); } @@ -2913,10 +2918,22 @@ function commitPassiveMountOnFiber( // caused them if (markerTransitions !== null) { markerTransitions.forEach(transition => { - if (instance.transitions.has(transition)) { - instance.pendingMarkers.add( - markerInstance.pendingSuspenseBoundaries, - ); + 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, + ); + } + } } }); } diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index 7f596a12641cc..4c1cb2226c961 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -25,6 +25,7 @@ import type {Wakeable} from 'shared/ReactTypes'; import type { OffscreenState, OffscreenInstance, + OffscreenQueue, } from './ReactFiberOffscreenComponent'; import type {HookFlags} from './ReactHookEffectTags'; import type {Cache} from './ReactFiberCacheComponent.old'; @@ -2877,8 +2878,8 @@ function commitPassiveMountOnFiber( if (enableTransitionTracing) { const isFallback = finishedWork.memoizedState; - const queue = (finishedWork.updateQueue: any); - const instance = finishedWork.stateNode; + const queue: OffscreenQueue = (finishedWork.updateQueue: any); + const instance: OffscreenInstance = finishedWork.stateNode; if (queue !== null) { if (isFallback) { @@ -2896,7 +2897,11 @@ function commitPassiveMountOnFiber( // Add all the transitions saved in the update queue during // the render phase (ie the transitions associated with this boundary) // into the transitions set. - prevTransitions.add(transition); + if (prevTransitions === null) { + // TODO: What if prevTransitions is null? + } else { + prevTransitions.add(transition); + } }); } @@ -2913,10 +2918,22 @@ function commitPassiveMountOnFiber( // caused them if (markerTransitions !== null) { markerTransitions.forEach(transition => { - if (instance.transitions.has(transition)) { - instance.pendingMarkers.add( - markerInstance.pendingSuspenseBoundaries, - ); + 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, + ); + } + } } }); } diff --git a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js index 0eb87bc3d6dbd..23d02575c1fa0 100644 --- a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js +++ b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js @@ -43,7 +43,7 @@ export type BatchConfigTransition = { export type TracingMarkerInstance = {| pendingSuspenseBoundaries: PendingSuspenseBoundaries | null, transitions: Set | null, -|} | null; +|}; export type PendingSuspenseBoundaries = Map; diff --git a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js index 6f25d1f72b825..0bbdd053883f4 100644 --- a/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js +++ b/packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js @@ -43,7 +43,7 @@ export type BatchConfigTransition = { export type TracingMarkerInstance = {| pendingSuspenseBoundaries: PendingSuspenseBoundaries | null, transitions: Set | null, -|} | null; +|}; export type PendingSuspenseBoundaries = Map;