Skip to content

Commit

Permalink
Use the name of the inner most parent for messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jun 8, 2024
1 parent 1954f61 commit 3281087
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/react-reconciler/src/getComponentNameFromFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
LegacyHiddenComponent,
CacheComponent,
TracingMarkerComponent,
Throw,
} from 'react-reconciler/src/ReactWorkTags';
import getComponentNameFromType from 'shared/getComponentNameFromType';
import {REACT_STRICT_MODE_TYPE} from 'shared/ReactSymbols';
Expand Down Expand Up @@ -160,6 +161,25 @@ export default function getComponentNameFromFiber(fiber: Fiber): string | null {
if (enableLegacyHidden) {
return 'LegacyHidden';
}
case Throw: {
if (__DEV__) {
// For an error in child position we use the of the inner most parent component.
// Whether a Server Component or the parent Fiber.
const debugInfo = fiber._debugInfo;
if (debugInfo != null) {
for (let i = debugInfo.length - 1; i >= 0; i--) {
if (typeof debugInfo[i].name === 'string') {
return debugInfo[i].name;
}
}
}
if (fiber.return === null) {
return null;
}
return getComponentNameFromFiber(fiber.return);
}
return null;
}
}

return null;
Expand Down

0 comments on commit 3281087

Please sign in to comment.