-
-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infer displayName from function/class/variable name #30
Comments
You mean why it isn't listed in the README? Probably just an oversight from my side. |
wait. does the displayName already appear in there? |
I don’t think it does... this is the result of console.logging
|
I can't repro this btw. The |
Hmm.. so I have stateless components not getting a
|
Oh, the |
👍 ...does babel still follow that approach for displayName handling? |
@fkling, yes! (I know the question wasn't to me, but I'd love to have it this way :)) |
I don't know, will have to look into this. Seems reasonable to me though. PRs are also welcome ;) |
I vote @mik01aj for those one :) |
Babel will generate the display name for you when it is not supplied explicitly. 👍 to implementing a similar inferrance rule to react-docgen |
@iamdustan Would this be something that is feasible to implement? |
Maybe you could just use this plugin: https://github.com/gajus/babel-plugin-react-display-name |
I would love for react-docgen to be able to infer the name of a component based on the Component.name. Babel only creates a displayName for the I'll dig around react-docgen today and see if I can figure out a PR that might accomplish this. |
Is there a reason this wasn’t already included? Having a displayName with each description would be beneficial for tools that are using docgen without having to re-read the js file to detect the display name again.
This wasn’t that big of a deal with
React.createClass
orclass extends React.Component
since those are pretty limited call sites, but the stateless function components can get a bit gnarly in trying to infer their display names. The detection for these are already pretty solid in the #28 branch.The text was updated successfully, but these errors were encountered: