Comments (6)
It looks like facebook/react#17274 is supposed to fix this, but it doesn't because I'm still seeing this today:
Created from revision 23309eb38 on 5/18/2020.
from react-devtools-experimental.
@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, propTypes
works properly as well.
from react-devtools-experimental.
It's really strange. I'm having the same issue. Because you're doing PageStatus =
, it should pick that up as the display name.
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 export default connect(...)(PageStatus)
. That plugin is extract-hoc
:
https://github.com/quangbuule/extract-hoc
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, PageStatus
is clearly defined as the function's name.
Maybe this is an issue in the React.memo
function?
from react-devtools-experimental.
Anonymous is the fallback name that is displayed if the function has no intrinsic .name
or user-supplied .displayName
. Generally this means it was declared as an anonymous inline function, e.g. React.memo(props => ...)
.
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.
from react-devtools-experimental.
It looks like facebook/react#17274 is supposed to fix this, but it doesn't because I'm still seeing this today:
Created from revision 23309eb38 on 5/18/2020.
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
from react-devtools-experimental.
I showed the source code.
I wrapped function PageStatus (...) {...}
into React.memo
it's common practice to avoid Anonymous component names in the dev tools
from react-devtools-experimental.
Related Issues (20)
- Truncation of key prop in GUI HOT 1
- Improve HOC search UX HOT 1
- Profiling does not work in Chrome HOT 4
- Improve globaly state/props edition. HOT 3
- Don't show "context" for classes without either contextType or contextTypes HOT 9
- Doesn't scroll down to the component when inspecting HOT 10
- Potential issue when using typescript. HOT 3
- node type filtering HOT 4
- Hook names grabbing solution w/o changing api HOT 1
- Inspecting complex values HOT 5
- feat: support search by prop, state, hooks HOT 1
- Style editor doesn't support single quotes for string values HOT 2
- The Context hook is not shown unless another hook is also presen like useState or useEffect HOT 7
- can not edit state with version `2f1c100` HOT 2
- Document/allow custom panel/extensions HOT 1
- Occasional FOUC when loading DevTools HOT 1
- Tooltips appear to be Times New Roman in Firefox HOT 2
- An easier way to see all siblings HOT 1
- Fully disable 0.14 support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-devtools-experimental.