From 746e103e84db135bf18a406a5450c6a4b57cff56 Mon Sep 17 00:00:00 2001 From: Sebastian Sebbie Silbermann Date: Tue, 11 Nov 2025 11:03:58 +0100 Subject: [PATCH] [DevTools] Send root unmount as a regular removal operation --- .../src/backend/fiber/renderer.js | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js index 8b7e20dcf09f1..1a7586a4c5488 100644 --- a/packages/react-devtools-shared/src/backend/fiber/renderer.js +++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js @@ -2159,7 +2159,6 @@ export function attach( let pendingOperationsQueue: Array | null = []; const pendingStringTable: Map = new Map(); let pendingStringTableLength: number = 0; - let pendingUnmountedRootID: FiberInstance['id'] | null = null; function pushOperation(op: number): void { if (__DEV__) { @@ -2187,8 +2186,7 @@ export function attach( pendingOperations.length === 0 && pendingRealUnmountedIDs.length === 0 && pendingRealUnmountedSuspenseIDs.length === 0 && - pendingSuspenderChanges.size === 0 && - pendingUnmountedRootID === null + pendingSuspenderChanges.size === 0 ); } @@ -2250,9 +2248,7 @@ export function attach( return; } - const numUnmountIDs = - pendingRealUnmountedIDs.length + - (pendingUnmountedRootID === null ? 0 : 1); + const numUnmountIDs = pendingRealUnmountedIDs.length; const numUnmountSuspenseIDs = pendingRealUnmountedSuspenseIDs.length; const numSuspenderChanges = pendingSuspenderChanges.size; @@ -2330,11 +2326,6 @@ export function attach( for (let j = 0; j < pendingRealUnmountedIDs.length; j++) { operations[i++] = pendingRealUnmountedIDs[j]; } - // The root ID should always be unmounted last. - if (pendingUnmountedRootID !== null) { - operations[i] = pendingUnmountedRootID; - i++; - } } // Fill in pending operations. @@ -2382,7 +2373,6 @@ export function attach( pendingRealUnmountedIDs.length = 0; pendingRealUnmountedSuspenseIDs.length = 0; pendingSuspenderChanges.clear(); - pendingUnmountedRootID = null; pendingStringTable.clear(); pendingStringTableLength = 0; } @@ -2868,7 +2858,6 @@ export function attach( // Already disconnected. return; } - const fiber = fiberInstance.data; if (trackedPathMatchInstance === fiberInstance) { // We're in the process of trying to restore previous selection. @@ -2878,17 +2867,7 @@ export function attach( } const id = fiberInstance.id; - const isRoot = fiber.tag === HostRoot; - if (isRoot) { - // Roots must be removed only after all children have been removed. - // So we track it separately. - pendingUnmountedRootID = id; - } else { - // To maintain child-first ordering, - // we'll push it into one of these queues, - // and later arrange them in the correct order. - pendingRealUnmountedIDs.push(id); - } + pendingRealUnmountedIDs.push(id); } function recordSuspenseResize(suspenseNode: SuspenseNode): void {