-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[utils] Add support for forwardRef components in getDisplayName #14429
[utils] Add support for forwardRef components in getDisplayName #14429
Conversation
@@ -51,6 +51,7 @@ module.exports = { | |||
'react/no-find-dom-node': 'off', | |||
|
|||
'jsx-a11y/no-autofocus': 'off', // We are a library, people do what they want. | |||
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }], |
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.
This is also required for react-dev-tools
to generate a meaningful display name for forwardRef
components. The correct exception would be to allow them only in forwardRef
.
e1f5ebd
to
6a03bd6
Compare
@@ -28,13 +28,13 @@ module.exports = [ | |||
name: 'The size of the @material-ui/core modules', | |||
webpack: true, | |||
path: 'packages/material-ui/build/index.js', | |||
limit: '91.3 KB', | |||
limit: '91.2 KB', |
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.
@@ -28,7 +28,6 @@ describe('<MenuList />', () => { | |||
}); | |||
|
|||
it('should render a List', () => { | |||
assert.strictEqual(wrapper.name(), 'List'); |
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.
Not sure why you would test here for that specific component. Would ul
be enough or some html element that matches those semantics?
}, | ||
{ | ||
name: 'The size of the @material-ui/styles modules', | ||
webpack: true, | ||
path: 'packages/material-ui-styles/build/index.js', | ||
limit: '16.3 KB', | ||
limit: '16.4 KB', |
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.
For some reason @material-ui/utils
appears in the styles bundle. Tree shaking is working fine but the dependency is not removed in a production bundle. It doesn't appear in the core bundle though.
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.
It does not appear in the esm bundle. I would keep this for now and revisit what bundles we monitor for size later.
Cherry picked logic from reacts
shared/getComponentName
to handleforwardRef
components.Allows to skip setting
displayName
manually which also affected production bundles. We can remove this logic while retaining a meaningfuldisplayName
in a dev environment.I suspect that this also helps folks that used display name selectors in enzyme and problematic testing habits. They should now get original e.g.
Backdrop
function component instead of theforwardRef
wrapper.