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

* Clear fields on unmount of fiber to avoid memory leak
This commit is contained in:
Dominic Gannaway 2018-11-19 16:09:11 +00:00 committed by GitHub
parent 592676503c
commit 0e9cb3f5d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -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;
}
}