-
Notifications
You must be signed in to change notification settings - Fork 55
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
Some memo components displaying as Anonymous #372
Comments
Anonymous is the fallback name that is displayed if the function has no intrinsic You can "hide" them if you want, using a component filter with a "name" of "Anonymous" but it would probably be better to use a named function so they show up in the tree with meaningful names. This isn't a DevTools bug so I'm going to close this issue. |
I showed the source code. I wrapped it's common practice to avoid Anonymous component names in the dev tools |
It's really strange. I'm having the same issue. Because you're doing I even tried doing: PageStatus.displayName = 'PageStatus'
PageStatus.name = 'PageStatus' Neither worked. Something's weird about how react handles memoized functions. I think the goal here is for you to do: const MemoizedPageStatus = memo(PageStatus) In the past, I had to use a Babel plugin to get components wrapped by higher-order components to show up with the correct name. This was especially important when doing I'd prefer to not rely on a 3rd party lib. In this particular instance, I don't have this plugin loaded nor have I tested it in a few years. The point I'm saying is that I had to work around this in the past, but only when the exported name was non-existent. In this case, Maybe this is an issue in the |
It looks like facebook/react#17274 is supposed to fix this, but it doesn't because I'm still seeing this today:
|
I changed const PageStatus = React.memo(
function PageStatus ({
splash, inline, loadingText, onHideError, successText: defaultSuccessText,
style, className, propses, classes, theme, errorIcon, errorPrefix, // стилизация
error, loading, success, // статус
}) {
// ...
}); to const PageStatus = function PageStatus ({
splash, inline, loadingText, onHideError, successText: defaultSuccessText,
style, className, propses, classes, theme, errorIcon, errorPrefix, // стилизация
error, loading, success, // статус
}) {
// ...
}
export default React.memo(PageStatus); And the component name displayed correctly in the devtools. This is most likely relared to the following question |
@mateja176 Correct. The working solution I have today is similar, but more-specific: const propTypes = {}
const MyComponent = () => <div />
MyComponent.propTypes = propTypes
const MemoizedMyComponent = memo(MyComponent)
export default MemoizedMyComponent This way, |
I want to hide useless Anonymous wrappers in devtools
The text was updated successfully, but these errors were encountered: