React-devtools: Missing component names

Created on 3 Jan 2014  ·  9Comments  ·  Source: facebook/react-devtools

Is there any reason why component names are always "Unknown"?

Just in case, I'm using browserify and sources are not minified, only concatenated.

Here's how it looks like:
image

Most helpful comment

I am using the chrome plugin React Developer Tools and when I inspect the React tree I see 'Proxy Component' instead of the components actual name. Might be a webpack issue? I tried adding 'displayName' and that didn't do it.

Anyone else run into this issue?

All 9 comments

OK, here's quick update: if component is exposed like this, it'll have Unknown as a name:

exports.MyComponent = React.createClass({...});

However, when I change it to this, it starts to work:

var MyComponent = React.createClass({...});
exports.MyComponent = MyComponent;

I checked extension source code, but can't figure what's tagName and how it is set.

If you are not using JSX, you need to add a displayName attribute to your class.

var MyComponent = React.createClass({
  displayName: 'MyComponent',
  ...
});

If you are using JSX, this is done automatically. Unfortunately there isn't a way to get it otherwise.

Yes, I'm using JSX. So, it seems it is different issue - JSX compiler can not contribute displayName if component is declared with exports.ComponentName = React.createClass().

JSX could in theory support your format too. This problem is going away when we move to ES6 classes or something similar though.

The tagName is something that's part of DOM components in React's core. It doesn't have a displayName.

Understood, thanks. Manual displayName will work for now.

Just made https://github.com/facebook/react/pull/799 which should fix this for all cases that I can think of.

I am using the chrome plugin React Developer Tools and when I inspect the React tree I see 'Proxy Component' instead of the components actual name. Might be a webpack issue? I tried adding 'displayName' and that didn't do it.

Anyone else run into this issue?

Was this page helpful?
0 / 5 - 0 ratings