`displayName` from memoized components should be taken into account in DevTools
See original GitHub issueIf you create a component via React.memo
and then explicitly provide it with a displayName
, DevTools ignore this display name.
React version: 16.12.0 DevTools version: 4.4.0
Steps To Reproduce
- Create a component like:
const FancyMemoComponent = React.memo(() => 'Check my name in DevTools')
- Provide it with a
displayName
FancyMemoComponent.displayName = 'FancyMemoComponent'
- Check its name in DevTools.
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:
FancyMemoComponent.type.displayName = 'FancyMemoComponent'
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:10
Top Results From Across the Web
When is it required to manually set the displayName for a ...
When I used the React dev tools to profile my inputs I found that each input had the same display name as the...
Read more >How To Debug React Components Using React Developer ...
It is not necessary to add a displayName , but it does help to navigate components when analyzing the component tree in the...
Read more >Avoid anonymous components with `displayName` - Jules Blom
Context objects have a displayName property that you can set to a helpful name and React will use it in debugging messages. The...
Read more >How to settle the React memoization debate - Medium
React's memo utility allows a developer to control when a component will re-render based on its props. It's a direct replacement for the ......
Read more >Faster React Apps With Memoization - Pixie Labs Blog
TL;DR: Most of our React components were re-rendering too often. Memoizing them fixed it. We used React Dev Tools and Why Did You...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have a alternative solution to fix it by myself when React have not fix it
Its easy to replace and not change any api
This is still an issue as outlined by the linked sandbox. Not solved.