mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
[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" />
This commit is contained in:
parent
ec7d9a7249
commit
bf11d2fb2f
|
|
@ -16,7 +16,7 @@ export default function useInferredName(
|
|||
const fetchFileWithCaching = useContext(FetchFileWithCachingContext);
|
||||
const name = asyncInfo.awaited.name;
|
||||
let inferNameFromStack = null;
|
||||
if (!name || name === 'Promise') {
|
||||
if (!name || name === 'Promise' || name === 'lazy') {
|
||||
// If all we have is a generic name, we can try to infer a better name from
|
||||
// the stack. We only do this if the stack has more than one frame since
|
||||
// otherwise it's likely to just be the name of the component which isn't better.
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export function getIODescription(value: mixed): string {
|
|||
}
|
||||
try {
|
||||
switch (typeof value) {
|
||||
case 'function':
|
||||
return value.name || '';
|
||||
case 'object':
|
||||
// Test the object for a bunch of common property names that are useful identifiers.
|
||||
// While we only have the return value here, it should ideally be a name that
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user