@@ -2783,15 +2783,12 @@ function flushPassiveUnmountEffects(firstChild: Fiber): void {
2783
2783
primarySubtreeTag !== NoSubtreeTag ||
2784
2784
primaryEffectTag !== NoEffect
2785
2785
) {
2786
- flushPassiveUnmountEffects ( fiberToDelete ) ;
2786
+ flushPassiveUnmountEffectsInsideOfDeletedTree ( fiberToDelete ) ;
2787
2787
}
2788
2788
2789
2789
// Now that passive effects have been processed, it's safe to detach lingering pointers.
2790
2790
detachFiberAfterEffects ( fiberToDelete ) ;
2791
2791
}
2792
-
2793
- // Clear deletions now that passive effects have been procssed.
2794
- fiber . deletions = null ;
2795
2792
}
2796
2793
2797
2794
const child = fiber . child ;
@@ -2822,6 +2819,39 @@ function flushPassiveUnmountEffects(firstChild: Fiber): void {
2822
2819
}
2823
2820
}
2824
2821
2822
+ function flushPassiveUnmountEffectsInsideOfDeletedTree (
2823
+ firstChild : Fiber ,
2824
+ ) : void {
2825
+ let fiber = firstChild ;
2826
+ while ( fiber !== null ) {
2827
+ const child = fiber . child ;
2828
+ if ( child !== null ) {
2829
+ // If any children have passive effects then traverse the subtree.
2830
+ // Note that this requires checking subtreeTag of the current Fiber,
2831
+ // rather than the subtreeTag/effectsTag of the first child,
2832
+ // since that would not cover passive effects in siblings.
2833
+ const primarySubtreeTag = fiber . subtreeTag & PassiveSubtreeTag ;
2834
+ if ( primarySubtreeTag !== NoSubtreeTag ) {
2835
+ flushPassiveUnmountEffectsInsideOfDeletedTree ( child ) ;
2836
+ }
2837
+ }
2838
+
2839
+ switch ( fiber . tag ) {
2840
+ case FunctionComponent :
2841
+ case ForwardRef :
2842
+ case SimpleMemoComponent :
2843
+ case Block : {
2844
+ const primaryEffectTag = fiber . effectTag & Passive ;
2845
+ if ( primaryEffectTag !== NoEffect ) {
2846
+ flushPassiveUnmountEffectsImpl ( fiber ) ;
2847
+ }
2848
+ }
2849
+ }
2850
+
2851
+ fiber = fiber . sibling ;
2852
+ }
2853
+ }
2854
+
2825
2855
function flushPassiveUnmountEffectsImpl ( fiber : Fiber ) : void {
2826
2856
const updateQueue : FunctionComponentUpdateQueue | null = ( fiber . updateQueue : any ) ;
2827
2857
const lastEffect = updateQueue !== null ? updateQueue . lastEffect : null ;
0 commit comments