@samitouri / QOS-React / commits / ab5b379275

Re-land "Clean up host pointers in level 2 of clean-up flag (#21112)"

This re-lands commit 8ed0c85bf174ce6e501be62d9ccec1889bbdbce1.

Andrew Clark committed May 3, 2021 at 13:34 UTC ab5b3792752385c7dcb5ad7ecd6bd9f0aa589f01
2 files changed +24 -18
packages/react-reconciler/src/ReactFiberCommitWork.new.js
+12 -9
@@ -1382,6 +1382,18 @@ function detachFiberAfterEffects(fiber: Fiber) {
1382 fiber.deletions = null;
1383 fiber.sibling = null;
1384
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 +
1397 // I'm intentionally not clearing the `return` field in this level. We
1398 // already disconnect the `return` pointer at the root of the deleted
1399 // subtree (in `detachFiberMutation`). Besides, `return` by itself is not
@@ -1400,15 +1412,6 @@ function detachFiberAfterEffects(fiber: Fiber) {
1412 // The purpose of this branch is to be super aggressive so we can measure
1413 // if there's any difference in memory impact. If there is, that could
1414 // 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 -
1415 fiber.return = null;
1416 fiber.dependencies = null;
1417 fiber.memoizedProps = null;
packages/react-reconciler/src/ReactFiberCommitWork.old.js
+12 -9
@@ -1382,6 +1382,18 @@ function detachFiberAfterEffects(fiber: Fiber) {
1382 fiber.deletions = null;
1383 fiber.sibling = null;
1384
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 +
1397 // I'm intentionally not clearing the `return` field in this level. We
1398 // already disconnect the `return` pointer at the root of the deleted
1399 // subtree (in `detachFiberMutation`). Besides, `return` by itself is not
@@ -1400,15 +1412,6 @@ function detachFiberAfterEffects(fiber: Fiber) {
1412 // The purpose of this branch is to be super aggressive so we can measure
1413 // if there's any difference in memory impact. If there is, that could
1414 // 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 -
1415 fiber.return = null;
1416 fiber.dependencies = null;
1417 fiber.memoizedProps = null;