From f61dd67e1f25230a3f872de23f91f188e15a8502 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Tue, 13 Nov 2018 11:47:31 +0000 Subject: [PATCH 1/3] Clear memoizedState on unmount of fiber --- packages/react-reconciler/src/ReactFiberCommitWork.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index 55a39ee640db8..a448b3ca188c3 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -728,9 +728,11 @@ function detachFiber(current: Fiber) { // itself will be GC:ed when the parent updates the next time. current.return = null; current.child = null; + current.memoizedState = null; if (current.alternate) { current.alternate.child = null; current.alternate.return = null; + current.alternate.memoizedState = null; } } From b4c1193b79ebcee9e780b24ee63ff8147b90a816 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Fri, 16 Nov 2018 08:51:18 +0000 Subject: [PATCH 2/3] Add other properties on the Fiber object --- packages/react-reconciler/src/ReactFiberCommitWork.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index a448b3ca188c3..fdba7ba186b03 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -729,10 +729,18 @@ function detachFiber(current: Fiber) { current.return = null; current.child = null; current.memoizedState = null; + current.updateQueue = null; + current.firstEffect = null; + current.lastEffect = null; + current.nextEffect = null; if (current.alternate) { - current.alternate.child = null; current.alternate.return = null; + current.alternate.child = null; current.alternate.memoizedState = null; + current.alternate.updateQueue = null; + current.alternate.firstEffect = null; + current.alternate.lastEffect = null; + current.alternate.nextEffect = null; } } From 5d6539063d7cd91aca19dcf2f8f64ecae3a56a90 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Fri, 16 Nov 2018 09:09:40 +0000 Subject: [PATCH 3/3] remove nextEffect null out --- packages/react-reconciler/src/ReactFiberCommitWork.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index fdba7ba186b03..0dc3d27f1dcfb 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -726,13 +726,13 @@ function detachFiber(current: Fiber) { // get GC:ed but we don't know which for sure which parent is the current // one so we'll settle for GC:ing the subtree of this child. This child // itself will be GC:ed when the parent updates the next time. + // We do not null out the 'nextEffect' field as it causes tests to fail. current.return = null; current.child = null; current.memoizedState = null; current.updateQueue = null; current.firstEffect = null; current.lastEffect = null; - current.nextEffect = null; if (current.alternate) { current.alternate.return = null; current.alternate.child = null; @@ -740,7 +740,6 @@ function detachFiber(current: Fiber) { current.alternate.updateQueue = null; current.alternate.firstEffect = null; current.alternate.lastEffect = null; - current.alternate.nextEffect = null; } }