Skip to content

Commit c8776cb

Browse files
committed
Pass instance to recordUnmount
We're no longer looking it up and we know it exists.
1 parent f6d24e1 commit c8776cb

File tree

1 file changed

+3
-15
lines changed
  • packages/react-devtools-shared/src/backend/fiber

1 file changed

+3
-15
lines changed

packages/react-devtools-shared/src/backend/fiber/renderer.js

+3-15
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,8 @@ export function attach(
21842184
return fiberInstance;
21852185
}
21862186

2187-
function recordUnmount(fiber: Fiber): null | FiberInstance {
2187+
function recordUnmount(fiberInstance: FiberInstance): void {
2188+
const fiber = fiberInstance.data;
21882189
if (__DEBUG__) {
21892190
debug('recordUnmount()', fiber, null);
21902191
}
@@ -2201,18 +2202,6 @@ export function attach(
22012202
}
22022203
}
22032204

2204-
const fiberInstance = getFiberInstanceUnsafe(fiber);
2205-
if (fiberInstance === null) {
2206-
// If we've never seen this Fiber, it might be inside of a legacy render Suspense fragment (so the store is not even aware of it).
2207-
// In that case we can just ignore it or it will cause errors later on.
2208-
// One example of this is a Lazy component that never resolves before being unmounted.
2209-
//
2210-
// This also might indicate a Fast Refresh force-remount scenario.
2211-
//
2212-
// TODO: This is fragile and can obscure actual bugs.
2213-
return null;
2214-
}
2215-
22162205
const id = fiberInstance.id;
22172206
const isRoot = fiber.tag === HostRoot;
22182207
if (isRoot) {
@@ -2233,7 +2222,6 @@ export function attach(
22332222
idToRootMap.delete(id);
22342223
idToTreeBaseDurationMap.delete(id);
22352224
}
2236-
return fiberInstance;
22372225
}
22382226

22392227
// Running state of the remaining children from the previous version of this parent that
@@ -2456,7 +2444,7 @@ export function attach(
24562444
remainingReconcilingChildren = stashedRemaining;
24572445
}
24582446
if (instance.kind === FIBER_INSTANCE) {
2459-
recordUnmount(instance.data);
2447+
recordUnmount(instance);
24602448
}
24612449
removeChild(instance);
24622450
}

0 commit comments

Comments
 (0)