@samitouri / QOS-React-2 / commits / c0d7023a88

Replace WeakSet with return pointer check

Dan Abramov committed Apr 20, 2019 at 21:42 UTC c0d7023a88d33aad7f01125645cf8322a5e808b8
1 file changed +2 -12
src/backend/renderer.js
+2 -12
@@ -589,11 +589,6 @@ export function attach(
589 let pendingSimulatedUnmountedIDs: Array<number> = [];
590 let pendingOperationsQueue: Array<Uint32Array> | null = [];
591
592 - // We keep track of which Fibers have been reported as unmounted by React
593 - // during this commit phase so that we don't try to "hide" them or their
594 - // children when Suspense flips to fallback. These Fibers won't have IDs.
595 - let fibersUnmountedInThisCommitPhase: WeakSet<Fiber> = new WeakSet();
596 -
592 // TODO: we could make this layer DEV-only and write directly to pendingOperations.
593 let nextOperation: Array<number> = [];
594 function beginNextOperation(size: number): void {
@@ -683,7 +678,6 @@ export function attach(
678 pendingOperations.length = 0;
679 pendingRealUnmountedIDs.length = 0;
680 pendingSimulatedUnmountedIDs.length = 0;
686 - fibersUnmountedInThisCommitPhase = new WeakSet();
681 }
682
683 function recordMount(fiber: Fiber, parentFiber: Fiber | null) {
@@ -890,9 +884,8 @@ export function attach(
884
885 while (child !== null) {
886 // Record simulated unmounts children-first.
893 - // We might find real committed unmounts along the way--skip them.
894 - // Otherwise we would send duplicated messages for the same IDs.
895 - if (!fibersUnmountedInThisCommitPhase.has(child)) {
887 + // We skip nodes without return because those are real unmounts.
888 + if (child.return !== null) {
889 unmountFiberChildrenRecursively(child);
890 recordUnmount(child, true);
891 }
@@ -1167,9 +1160,6 @@ export function attach(
1160 }
1161
1162 function handleCommitFiberUnmount(fiber) {
1170 - // Remeber this is a real deletion so we don't
1171 - // go down this tree when hiding Suspense nodes.
1172 - fibersUnmountedInThisCommitPhase.add(fiber);
1163 // This is not recursive.
1164 // We can't traverse fibers after unmounting so instead
1165 // we rely on React telling us about each unmount.