[DevTools] Send root unmount as a regular removal operation (#35107)
Sebastian "Sebbie" Silbermann committed
Nov 11, 2025 at 23:08 UTC
8c15edd57c41871dc4f0b997a6501bb7b997ba7f
1 file changed
+3
-24
packages/react-devtools-shared/src/backend/fiber/renderer.js
+3
-24
@@ -2159,7 +2159,6 @@ export function attach(
2159
let pendingOperationsQueue: Array<OperationsArray> | null = [];
2160
const pendingStringTable: Map<string, StringTableEntry> = new Map();
2161
let pendingStringTableLength: number = 0;
2162
- let pendingUnmountedRootID: FiberInstance['id'] | null = null;
2162
2163
function pushOperation(op: number): void {
2164
if (__DEV__) {
@@ -2187,8 +2186,7 @@ export function attach(
2186
pendingOperations.length === 0 &&
2187
pendingRealUnmountedIDs.length === 0 &&
2188
pendingRealUnmountedSuspenseIDs.length === 0 &&
2190
- pendingSuspenderChanges.size === 0 &&
2191
- pendingUnmountedRootID === null
2189
+ pendingSuspenderChanges.size === 0
2190
);
2191
}
2192
@@ -2250,9 +2248,7 @@ export function attach(
2248
return;
2249
}
2250
2253
- const numUnmountIDs =
2254
- pendingRealUnmountedIDs.length +
2255
- (pendingUnmountedRootID === null ? 0 : 1);
2251
+ const numUnmountIDs = pendingRealUnmountedIDs.length;
2252
const numUnmountSuspenseIDs = pendingRealUnmountedSuspenseIDs.length;
2253
const numSuspenderChanges = pendingSuspenderChanges.size;
2254
@@ -2330,11 +2326,6 @@ export function attach(
2326
for (let j = 0; j < pendingRealUnmountedIDs.length; j++) {
2327
operations[i++] = pendingRealUnmountedIDs[j];
2328
}
2333
- // The root ID should always be unmounted last.
2334
- if (pendingUnmountedRootID !== null) {
2335
- operations[i] = pendingUnmountedRootID;
2336
- i++;
2337
- }
2329
}
2330
2331
// Fill in pending operations.
@@ -2382,7 +2373,6 @@ export function attach(
2373
pendingRealUnmountedIDs.length = 0;
2374
pendingRealUnmountedSuspenseIDs.length = 0;
2375
pendingSuspenderChanges.clear();
2385
- pendingUnmountedRootID = null;
2376
pendingStringTable.clear();
2377
pendingStringTableLength = 0;
2378
}
@@ -2868,7 +2858,6 @@ export function attach(
2858
// Already disconnected.
2859
return;
2860
}
2871
- const fiber = fiberInstance.data;
2861
2862
if (trackedPathMatchInstance === fiberInstance) {
2863
// We're in the process of trying to restore previous selection.
@@ -2878,17 +2867,7 @@ export function attach(
2867
}
2868
2869
const id = fiberInstance.id;
2881
- const isRoot = fiber.tag === HostRoot;
2882
- if (isRoot) {
2883
- // Roots must be removed only after all children have been removed.
2884
- // So we track it separately.
2885
- pendingUnmountedRootID = id;
2886
- } else {
2887
- // To maintain child-first ordering,
2888
- // we'll push it into one of these queues,
2889
- // and later arrange them in the correct order.
2890
- pendingRealUnmountedIDs.push(id);
2891
- }
2870
+ pendingRealUnmountedIDs.push(id);
2871
}
2872
2873
function recordSuspenseResize(suspenseNode: SuspenseNode): void {