Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Use filename as component name when exporting anonymous function as default #1294

Closed
sbussard opened this issue Feb 5, 2019 · 6 comments
Closed

Comments

@sbussard
Copy link

sbussard commented Feb 5, 2019

When a component is exported via an anonymous function

//...
export default () => <SomeComponent />;

It shows up as <Unknown> in react-devtools.
But I've noticed that react-devtools is able to identify which file the component came from, so it would be helpful to somehow use the filename instead of "Unknown" so that engineers don't have to change their coding style to use the inspect feature to the fullest.

@jcousins-ynap
Copy link

jcousins-ynap commented Feb 7, 2019

This also occurs in Higher Order Components

const Hello = ({ children }) => (<span>Hello {children}</span>);
const withWorld = (Component) => () => (<Component> world</Component>);
const HelloWorld = withWorld(Hello);

which renders

<Unknown>
  <Hello>
    <span>Hello world</span>
  </Hello>
</Unknown>

@bvaughn
Copy link
Contributor

bvaughn commented Aug 19, 2019

React DevTools has been rewritten and recently launched a new version 4 UI. The source code for this rewrite was done in a separate repository and now lives in the main React repo (github.com/facebook/react).

Because version 4 was a total rewrite, and all issues in this repository are related to the old version 3 of the extension, I am closing all issues in this repository. If you can still reproduce this issue, or believe this feature request is still relevant, please open a new issue in the React repo: https://github.com/facebook/react/issues/new?labels=Component:%20Developer%20Tools

@bvaughn bvaughn closed this as completed Aug 19, 2019
@jcousins-ynap
Copy link

Thanks for the update @bvaughn

@sbussard
Copy link
Author

@bvaughn the new version doesn't seem to show file names at all. Is there a way to enable that? With the codebase I work on it's absolutely critical to my workflow to have that feature.

@bvaughn
Copy link
Contributor

bvaughn commented Aug 29, 2019

This little button logs info about the component (including the file name) to the console:
Screen Shot 2019-08-29 at 8 36 32 AM

Related issue on the new repo: facebook/react#16497

@sbussard
Copy link
Author

sbussard commented Sep 3, 2019

Awesome! Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants