From c0d7023a88d33aad7f01125645cf8322a5e808b8 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 20 Apr 2019 21:42:30 +0100 Subject: [PATCH 1/2] Replace WeakSet with return pointer check --- src/backend/renderer.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/backend/renderer.js b/src/backend/renderer.js index 728f1c0e59..a4626740b3 100644 --- a/src/backend/renderer.js +++ b/src/backend/renderer.js @@ -589,11 +589,6 @@ export function attach( let pendingSimulatedUnmountedIDs: Array = []; let pendingOperationsQueue: Array | 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 = new WeakSet(); - // TODO: we could make this layer DEV-only and write directly to pendingOperations. let nextOperation: Array = []; 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. From 006e03c38e191303b797cb69c35cec1f1069c7cd Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 20 Apr 2019 22:17:12 +0100 Subject: [PATCH 2/2] Ignore leading edge of find-by-DOM throttle --- src/backend/agent.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/agent.js b/src/backend/agent.js index 74676d44b9..378a70f271 100644 --- a/src/backend/agent.js +++ b/src/backend/agent.js @@ -525,6 +525,9 @@ export default class Agent extends EventEmitter { this._bridge.send('selectFiber', id); } }), - 200 + 200, + // Don't change the selection in the very first 200ms + // because those are usually unintentional as you lift the cursor. + { leading: false } ); }