GithubHelp home page GithubHelp logo

Comments (9)

fresh5447 avatar fresh5447 commented on April 20, 2024 3

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?

from react-devtools.

mrjoes avatar mrjoes commented on April 20, 2024

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.

from react-devtools.

vjeux avatar vjeux commented on April 20, 2024

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.

from react-devtools.

mrjoes avatar mrjoes commented on April 20, 2024

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().

from react-devtools.

vjeux avatar vjeux commented on April 20, 2024

This is the code responsible for it: https://github.com/facebook/react/blob/master/vendor/fbtransform/transforms/reactDisplayName.js#L37

from react-devtools.

sebmarkbage avatar sebmarkbage commented on April 20, 2024

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.

from react-devtools.

sebmarkbage avatar sebmarkbage commented on April 20, 2024

If you want to send a pull request you could add your preferred formats here:

https://github.com/facebook/react/blob/ab47e992155ec9c2455b02bf671e8dd92bd01055/vendor/fbtransform/transforms/reactDisplayName.js#L37-L51

from react-devtools.

mrjoes avatar mrjoes commented on April 20, 2024

Understood, thanks. Manual displayName will work for now.

from react-devtools.

sophiebits avatar sophiebits commented on April 20, 2024

Just made facebook/react#799 which should fix this for all cases that I can think of.

from react-devtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.