fix: consider alternate as a key for componentLogsEntry when inspecting raw fiber instance (#31009)
Related - https://github.com/facebook/react/pull/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.
Ruslan Lesiutin committed
Sep 24, 2024 at 17:49 UTC
fc4a33eaa9c935ac860ab6043b95d55540068571
1 file changed
+8
-1
packages/react-devtools-shared/src/backend/fiber/renderer.js
+8
-1
@@ -1029,6 +1029,10 @@ export function attach(
1029
if (devtoolsInstance.kind === FIBER_INSTANCE) {
1030
const fiber = devtoolsInstance.data;
1031
componentLogsEntry = fiberToComponentLogsMap.get(fiber);
1032
+
1033
+ if (componentLogsEntry === undefined && fiber.alternate !== null) {
1034
+ componentLogsEntry = fiberToComponentLogsMap.get(fiber.alternate);
1035
+ }
1036
} else {
1037
const componentInfo = devtoolsInstance.data;
1038
componentLogsEntry = componentInfoToComponentLogsMap.get(componentInfo);
@@ -4248,7 +4252,10 @@ export function attach(
4252
source = getSourceForFiberInstance(fiberInstance);
4253
}
4254
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
+ }
4259
4260
return {
4261
id: fiberInstance.id,