mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #204 from gaearon/no-weakset
Replace WeakSet with return pointer check
This commit is contained in:
+2
-12
@@ -589,11 +589,6 @@ export function attach(
|
||||
let pendingSimulatedUnmountedIDs: Array<number> = [];
|
||||
let pendingOperationsQueue: Array<Uint32Array> | null = [];
|
||||
|
||||
// We keep track of which Fibers have been reported as unmounted by React
|
||||
// during this commit phase so that we don't try to "hide" them or their
|
||||
// children when Suspense flips to fallback. These Fibers won't have IDs.
|
||||
let fibersUnmountedInThisCommitPhase: WeakSet<Fiber> = new WeakSet();
|
||||
|
||||
// TODO: we could make this layer DEV-only and write directly to pendingOperations.
|
||||
let nextOperation: Array<number> = [];
|
||||
function beginNextOperation(size: number): void {
|
||||
@@ -683,7 +678,6 @@ export function attach(
|
||||
pendingOperations.length = 0;
|
||||
pendingRealUnmountedIDs.length = 0;
|
||||
pendingSimulatedUnmountedIDs.length = 0;
|
||||
fibersUnmountedInThisCommitPhase = new WeakSet();
|
||||
}
|
||||
|
||||
function recordMount(fiber: Fiber, parentFiber: Fiber | null) {
|
||||
@@ -890,9 +884,8 @@ export function attach(
|
||||
|
||||
while (child !== null) {
|
||||
// Record simulated unmounts children-first.
|
||||
// We might find real committed unmounts along the way--skip them.
|
||||
// Otherwise we would send duplicated messages for the same IDs.
|
||||
if (!fibersUnmountedInThisCommitPhase.has(child)) {
|
||||
// We skip nodes without return because those are real unmounts.
|
||||
if (child.return !== null) {
|
||||
unmountFiberChildrenRecursively(child);
|
||||
recordUnmount(child, true);
|
||||
}
|
||||
@@ -1167,9 +1160,6 @@ export function attach(
|
||||
}
|
||||
|
||||
function handleCommitFiberUnmount(fiber) {
|
||||
// Remeber this is a real deletion so we don't
|
||||
// go down this tree when hiding Suspense nodes.
|
||||
fibersUnmountedInThisCommitPhase.add(fiber);
|
||||
// This is not recursive.
|
||||
// We can't traverse fibers after unmounting so instead
|
||||
// we rely on React telling us about each unmount.
|
||||
|
||||
Reference in New Issue
Block a user