Skip to content

Commit fc4a33e

Browse files
authored
fix: consider alternate as a key for componentLogsEntry when inspecting raw fiber instance (#31009)
Related - #30899. Looks like this was missed. We actually do this when we record errors and warnings before sending them via Bridge: https://github.com/facebook/react/blob/e4953922a99b5477c3bcf98cdaa2b13ac0a81f0d/packages/react-devtools-shared/src/backend/fiber/renderer.js#L2169-L2173 So, what is happening in the end, errors or warnings are displayed in the Tree, but when user clicks on the component, nothing is shown, because `fiberToComponentLogsMap` has only `alternate` as a key.
1 parent 04bd67a commit fc4a33e

File tree

1 file changed

+8
-1
lines changed
  • packages/react-devtools-shared/src/backend/fiber

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,10 @@ export function attach(
10291029
if (devtoolsInstance.kind === FIBER_INSTANCE) {
10301030
const fiber = devtoolsInstance.data;
10311031
componentLogsEntry = fiberToComponentLogsMap.get(fiber);
1032+
1033+
if (componentLogsEntry === undefined && fiber.alternate !== null) {
1034+
componentLogsEntry = fiberToComponentLogsMap.get(fiber.alternate);
1035+
}
10321036
} else {
10331037
const componentInfo = devtoolsInstance.data;
10341038
componentLogsEntry = componentInfoToComponentLogsMap.get(componentInfo);
@@ -4248,7 +4252,10 @@ export function attach(
42484252
source = getSourceForFiberInstance(fiberInstance);
42494253
}
42504254

4251-
const componentLogsEntry = fiberToComponentLogsMap.get(fiber);
4255+
let componentLogsEntry = fiberToComponentLogsMap.get(fiber);
4256+
if (componentLogsEntry === undefined && fiber.alternate !== null) {
4257+
componentLogsEntry = fiberToComponentLogsMap.get(fiber.alternate);
4258+
}
42524259

42534260
return {
42544261
id: fiberInstance.id,

0 commit comments

Comments
 (0)