-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[core] Update getDisplayName to handle React.memo #19762
Conversation
getDisplayName handles forwardRef() but not memo() as a result when memo() is used with withStyles() the displayName is not passed on and css classes do not get proper names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great pull request.
What about the changes to the examples/? Was this by accident?
@@ -50,6 +50,8 @@ export default function getDisplayName(Component) { | |||
switch (Component.$$typeof) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder, could isFragment
and isMemo
be used instead to avoid React's internals access?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried switching to typeOf(Component)
, however IIRC it appeared that for memo typeOf
actually returns Component.type.$$typeof
. Not sure isMemo would work since most of the is*
functions use typeOf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so it's already as good as it can get.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Details of bundle changes.Comparing: f2d74e9...1ae3d94
|
I hope we will able to rely on React's API soon :) @dantman Well done! |
I guess the core team doesn't want to add public method for this since it's only useful for hoc in the first place. Hooks are the future. Though they will deny that class components are legacy (which they apparently are looking at the display name issue) 😆 |
getDisplayName handles forwardRef() but not memo() as a result when memo() is used with withStyles() the displayName is not passed on and css classes do not get proper names.