Skip to content

Commit bf11d2f

Browse files
authored
[DevTools] Infer name from stack if it's the generic "lazy" name (#34907)
Stacked on #34906. Infer name from stack if it's the generic "lazy" name. It might be wrapped in an abstraction. E.g. `next/dynamic`. Also use the function name as a description of a resolved function value. <img width="310" height="166" alt="Screenshot 2025-10-18 at 10 42 05 AM" src="https://github.com/user-attachments/assets/c63170b9-2b19-4f30-be7a-6429bb3ef3d9" />
1 parent ec7d9a7 commit bf11d2f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/react-devtools-shared/src/devtools/views/useInferredName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function useInferredName(
1616
const fetchFileWithCaching = useContext(FetchFileWithCachingContext);
1717
const name = asyncInfo.awaited.name;
1818
let inferNameFromStack = null;
19-
if (!name || name === 'Promise') {
19+
if (!name || name === 'Promise' || name === 'lazy') {
2020
// If all we have is a generic name, we can try to infer a better name from
2121
// the stack. We only do this if the stack has more than one frame since
2222
// otherwise it's likely to just be the name of the component which isn't better.

packages/shared/ReactIODescription.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export function getIODescription(value: mixed): string {
1313
}
1414
try {
1515
switch (typeof value) {
16+
case 'function':
17+
return value.name || '';
1618
case 'object':
1719
// Test the object for a bunch of common property names that are useful identifiers.
1820
// While we only have the return value here, it should ideally be a name that

0 commit comments

Comments
 (0)