Skip to content

Commit

Permalink
fix: consider alternate as a key for componentLogsEntry when inspecti…
Browse files Browse the repository at this point in the history
…ng 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.
  • Loading branch information
hoxyq authored Sep 24, 2024
1 parent 04bd67a commit fc4a33e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/react-devtools-shared/src/backend/fiber/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,10 @@ export function attach(
if (devtoolsInstance.kind === FIBER_INSTANCE) {
const fiber = devtoolsInstance.data;
componentLogsEntry = fiberToComponentLogsMap.get(fiber);

if (componentLogsEntry === undefined && fiber.alternate !== null) {
componentLogsEntry = fiberToComponentLogsMap.get(fiber.alternate);
}
} else {
const componentInfo = devtoolsInstance.data;
componentLogsEntry = componentInfoToComponentLogsMap.get(componentInfo);
Expand Down Expand Up @@ -4248,7 +4252,10 @@ export function attach(
source = getSourceForFiberInstance(fiberInstance);
}

const componentLogsEntry = fiberToComponentLogsMap.get(fiber);
let componentLogsEntry = fiberToComponentLogsMap.get(fiber);
if (componentLogsEntry === undefined && fiber.alternate !== null) {
componentLogsEntry = fiberToComponentLogsMap.get(fiber.alternate);
}

return {
id: fiberInstance.id,
Expand Down

0 comments on commit fc4a33e

Please sign in to comment.