-
Notifications
You must be signed in to change notification settings - Fork 46.7k
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
displayName
from memoized components should be taken into account in DevTools
#18026
Comments
Same problem in #17876 They dont recommand modify |
I have a alternative solution to fix it by myself when React have not fix it import React, { PropsWithChildren, SFC } from 'react';
export const MyMemo = <P extends object>(
Component: SFC<P>,
propsAreEqual?: (
prevProps: Readonly<PropsWithChildren<P>>,
nextProps: Readonly<PropsWithChildren<P>>
) => boolean
) => {
const memoized = React.memo(Component, propsAreEqual);
Object.defineProperty(memoized, 'displayName', {
set(v) {
Component.displayName = v;
},
});
return memoized;
}; Its easy to replace and not change any api |
#18495 will fix this. |
I can see that when using const SignInForm: React.FC = React.memo(() => {
...
}); Does #18495 fix this? |
This issue is fixed in the latest release candidate for React 17. You can try it out with by installing |
Hi, This bug is not fixed in your codesandbox. |
Not working |
This is still an issue as outlined by the linked sandbox. Not solved. |
The App memo shows as "_c [Memo]" ([] are my attempt to simulate a block with background-color set) |
If you create a component via
React.memo
and then explicitly provide it with adisplayName
, DevTools ignore this display name.React version: 16.12.0
DevTools version: 4.4.0
Steps To Reproduce
displayName
Link to code example: https://codesandbox.io/s/react-memo-display-name-vk7gv
The current behavior
DevTools do not display the given
displayName
.The expected behavior
DevTools should display the given
displayName
.Comments
I am aware that the name can be picked from the function inside
React.memo
, but I prefer using anonymous functions.I am using this workaround:
The text was updated successfully, but these errors were encountered: