@@ -1097,27 +1097,23 @@ function commitNestedUnmounts(
10971097 }
10981098}
10991099
1100- function detachFiber ( current : Fiber ) {
1101- const alternate = current . alternate ;
1100+ function detachFiber ( fiber : Fiber ) {
11021101 // Cut off the return pointers to disconnect it from the tree. Ideally, we
11031102 // should clear the child pointer of the parent alternate to let this
11041103 // get GC:ed but we don't know which for sure which parent is the current
11051104 // one so we'll settle for GC:ing the subtree of this child. This child
11061105 // itself will be GC:ed when the parent updates the next time.
1107- current . return = null ;
1108- current . child = null ;
1109- current . memoizedState = null ;
1110- current . updateQueue = null ;
1111- current . dependencies = null ;
1112- current . alternate = null ;
1113- current . firstEffect = null ;
1114- current . lastEffect = null ;
1115- current . pendingProps = null ;
1116- current . memoizedProps = null ;
1117- current . stateNode = null ;
1118- if ( alternate !== null ) {
1119- detachFiber ( alternate ) ;
1120- }
1106+ fiber . return = null ;
1107+ fiber . child = null ;
1108+ fiber . memoizedState = null ;
1109+ fiber . updateQueue = null ;
1110+ fiber . dependencies = null ;
1111+ fiber . alternate = null ;
1112+ fiber . firstEffect = null ;
1113+ fiber . lastEffect = null ;
1114+ fiber . pendingProps = null ;
1115+ fiber . memoizedProps = null ;
1116+ fiber . stateNode = null ;
11211117}
11221118
11231119function emptyPortalContainer ( current : Fiber ) {
@@ -1485,7 +1481,11 @@ function commitDeletion(
14851481 // Detach refs and call componentWillUnmount() on the whole subtree.
14861482 commitNestedUnmounts ( finishedRoot , current , renderPriorityLevel ) ;
14871483 }
1484+ const alternate = current . alternate ;
14881485 detachFiber ( current ) ;
1486+ if ( alternate !== null ) {
1487+ detachFiber ( alternate ) ;
1488+ }
14891489}
14901490
14911491function commitWork ( current : Fiber | null , finishedWork : Fiber ) : void {
0 commit comments