Skip to content

Commit

Permalink
Clear fields on unmount of fiber to avoid memory leak (#14276)
Browse files Browse the repository at this point in the history
* Clear fields on unmount of fiber to avoid memory leak
  • Loading branch information
trueadm committed Nov 19, 2018
1 parent 5926765 commit 0e9cb3f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,14 @@ function detachFiber(current: Fiber) {
// itself will be GC:ed when the parent updates the next time.
current.return = null;
current.child = null;
if (current.alternate) {
current.alternate.child = null;
current.alternate.return = null;
current.memoizedState = null;
current.updateQueue = null;
const alternate = current.alternate;
if (alternate !== null) {
alternate.return = null;
alternate.child = null;
alternate.memoizedState = null;
alternate.updateQueue = null;
}
}

Expand Down

0 comments on commit 0e9cb3f

Please sign in to comment.