@@ -1015,30 +1015,19 @@ function commitNestedUnmounts(
1015
1015
}
1016
1016
1017
1017
function detachFiberMutation ( fiber : Fiber ) {
1018
- // Cut off the return pointers to disconnect it from the tree.
1019
- // Note that we can't clear child or sibling pointers yet,
1020
- // because they may be required for passive effects .
1021
- // These pointers will be cleared in a separate pass.
1022
- // Ideally, we should clear the child pointer of the parent alternate to let this
1018
+ // Cut off the return pointer to disconnect it from the tree.
1019
+ // This enables us to detect and warn against state updates on an unmounted component.
1020
+ // It also prevents events from bubbling from within disconnected components .
1021
+ //
1022
+ // Ideally, we should also clear the child pointer of the parent alternate to let this
1023
1023
// get GC:ed but we don't know which for sure which parent is the current
1024
- // one so we'll settle for GC:ing the subtree of this child. This child
1025
- // itself will be GC:ed when the parent updates the next time.
1026
- // Note: we cannot null out sibling here, otherwise it can cause issues
1027
- // with findDOMNode and how it requires the sibling field to carry out
1028
- // traversal in a later effect. See PR #16820. We now clear the sibling
1029
- // field after effects, see: detachFiberAfterEffects.
1030
- fiber . alternate = null ;
1031
- fiber . dependencies = null ;
1032
- fiber . firstEffect = null ;
1033
- fiber . lastEffect = null ;
1034
- fiber . memoizedProps = null ;
1035
- fiber . memoizedState = null ;
1036
- fiber . pendingProps = null ;
1024
+ // one so we'll settle for GC:ing the subtree of this child.
1025
+ // This child itself will be GC:ed when the parent updates the next time.
1026
+ //
1027
+ // Note that we can't clear child or sibling pointers yet.
1028
+ // They're needed for passive effects and for findDOMNode.
1029
+ // We defer those fields, and all other cleanup, to the passive phase (see detachFiberAfterEffects).
1037
1030
fiber . return = null ;
1038
- fiber . stateNode = null ;
1039
- if ( __DEV__ ) {
1040
- fiber . _debugOwner = null ;
1041
- }
1042
1031
}
1043
1032
1044
1033
function emptyPortalContainer ( current : Fiber ) {
0 commit comments