@@ -1382,6 +1382,18 @@ function detachFiberAfterEffects(fiber: Fiber) {
13821382 fiber . deletions = null ;
13831383 fiber . sibling = null ;
13841384
1385+ // The `stateNode` is cyclical because on host nodes it points to the host
1386+ // tree, which has its own pointers to children, parents, and siblings.
1387+ // The other host nodes also point back to fibers, so we should detach that
1388+ // one, too.
1389+ if ( fiber . tag === HostComponent ) {
1390+ const hostInstance : Instance = fiber . stateNode ;
1391+ if ( hostInstance !== null ) {
1392+ detachDeletedInstance ( hostInstance ) ;
1393+ }
1394+ }
1395+ fiber . stateNode = null ;
1396+
13851397 // I'm intentionally not clearing the `return` field in this level. We
13861398 // already disconnect the `return` pointer at the root of the deleted
13871399 // subtree (in `detachFiberMutation`). Besides, `return` by itself is not
@@ -1400,15 +1412,6 @@ function detachFiberAfterEffects(fiber: Fiber) {
14001412 // The purpose of this branch is to be super aggressive so we can measure
14011413 // if there's any difference in memory impact. If there is, that could
14021414 // indicate a React leak we don't know about.
1403-
1404- // For host components, disconnect host instance -> fiber pointer.
1405- if ( fiber . tag === HostComponent ) {
1406- const hostInstance : Instance = fiber . stateNode ;
1407- if ( hostInstance !== null ) {
1408- detachDeletedInstance ( hostInstance ) ;
1409- }
1410- }
1411-
14121415 fiber . return = null ;
14131416 fiber . dependencies = null ;
14141417 fiber . memoizedProps = null ;
0 commit comments