-
Notifications
You must be signed in to change notification settings - Fork 48.8k
devtools: Remove ForwardRef/Memo from display name if displayName
is set
#21952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import { | |
import { | ||
deletePathInObject, | ||
getDisplayName, | ||
getWrappedDisplayName, | ||
getDefaultComponentFilters, | ||
getInObject, | ||
getUID, | ||
|
@@ -451,10 +452,11 @@ export function getInternalReactConstants( | |
case IndeterminateComponent: | ||
return getDisplayName(resolvedType); | ||
case ForwardRef: | ||
// Mirror https://github.com/facebook/react/blob/7c21bf72ace77094fd1910cc350a548287ef8350/packages/shared/getComponentName.js#L27-L37 | ||
bvaughn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
(type && type.displayName) || | ||
getDisplayName(resolvedType, 'Anonymous') | ||
return getWrappedDisplayName( | ||
elementType, | ||
resolvedType, | ||
'ForwardRef', | ||
'Anonymous', | ||
); | ||
case HostRoot: | ||
const fiberRoot = fiber.stateNode; | ||
|
@@ -475,10 +477,12 @@ export function getInternalReactConstants( | |
return 'Lazy'; | ||
case MemoComponent: | ||
case SimpleMemoComponent: | ||
return ( | ||
(elementType && elementType.displayName) || | ||
(type && type.displayName) || | ||
getDisplayName(resolvedType, 'Anonymous') | ||
// Display name in React does not use `Memo` as a wrapper but fallback name. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should sync the display names for memo as well. React will compute |
||
return getWrappedDisplayName( | ||
elementType, | ||
resolvedType, | ||
'Memo', | ||
'Anonymous', | ||
); | ||
case SuspenseComponent: | ||
return 'Suspense'; | ||
|
Uh oh!
There was an error while loading. Please reload this page.