Skip to content

Commit 0e9cb3f

Browse files
authored
Clear fields on unmount of fiber to avoid memory leak (#14276)
* Clear fields on unmount of fiber to avoid memory leak
1 parent 5926765 commit 0e9cb3f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,14 @@ function detachFiber(current: Fiber) {
728728
// itself will be GC:ed when the parent updates the next time.
729729
current.return = null;
730730
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;
734739
}
735740
}
736741

0 commit comments

Comments
 (0)