@samitouri / QOS-React / commits / 0e9cb3f5d0

Clear fields on unmount of fiber to avoid memory leak (#14276)

* Clear fields on unmount of fiber to avoid memory leak

Dominic Gannaway committed Nov 19, 2018 at 16:09 UTC 0e9cb3f5d0bfd4fe08ac8fcfba71302559614282
1 file changed +8 -3
packages/react-reconciler/src/ReactFiberCommitWork.js
+8 -3
@@ -728,9 +728,14 @@ function detachFiber(current: Fiber) {
728 // itself will be GC:ed when the parent updates the next time.
729 current.return = null;
730 current.child = null;
731 - if (current.alternate) {
732 - current.alternate.child = null;
733 - current.alternate.return = null;
731 + current.memoizedState = null;
732 + current.updateQueue = null;
733 + const alternate = current.alternate;
734 + if (alternate !== null) {
735 + alternate.return = null;
736 + alternate.child = null;
737 + alternate.memoizedState = null;
738 + alternate.updateQueue = null;
739 }
740 }
741