Coder Social home page Coder Social logo

Comments (15)

fkling avatar fkling commented on April 28, 2024

You mean why it isn't listed in the README? Probably just an oversight from my side.

from react-docgen.

iamdustan avatar iamdustan commented on April 28, 2024

wait. does the displayName already appear in there?

from react-docgen.

iamdustan avatar iamdustan commented on April 28, 2024

I don’t think it does... this is the result of console.logging

docgen.parse(fs.readFileSync('./my-component.js'))
{ description: '@private',
  props:
   { to: { type: [Object], required: true, description: '' },
     name: { type: [Object], required: true, description: '' } } }

from react-docgen.

fkling avatar fkling commented on April 28, 2024

We do have https://github.com/reactjs/react-docgen/blob/master/src/handlers/displayNameHandler.js though.

from react-docgen.

fkling avatar fkling commented on April 28, 2024

I can't repro this btw. The displayName shows up in the result. What does your ./my-component.js look like?

from react-docgen.

iamdustan avatar iamdustan commented on April 28, 2024

Hmm..

so I have stateless components not getting a displayName as well as

import React, {PropTypes, Component} from 'react';
class Tabs extends Component {
  ....
}

export default Tabs;

from react-docgen.

fkling avatar fkling commented on April 28, 2024

Oh, the displayName handler only looks for explicit displayName properties. You want it to also return the inferred name from the class or function name, right?

from react-docgen.

iamdustan avatar iamdustan commented on April 28, 2024

πŸ‘

...does babel still follow that approach for displayName handling?

from react-docgen.

mik01aj avatar mik01aj commented on April 28, 2024

@fkling, yes! (I know the question wasn't to me, but I'd love to have it this way :))

from react-docgen.

fkling avatar fkling commented on April 28, 2024

I don't know, will have to look into this. Seems reasonable to me though. PRs are also welcome ;)

from react-docgen.

iamdustan avatar iamdustan commented on April 28, 2024

I vote @mik01aj for those one :)

from react-docgen.

AlanFoster avatar AlanFoster commented on April 28, 2024

Babel will generate the display name for you when it is not supplied explicitly.

πŸ‘ to implementing a similar inferrance rule to react-docgen

from react-docgen.

AlanFoster avatar AlanFoster commented on April 28, 2024

@iamdustan Would this be something that is feasible to implement?

from react-docgen.

mik01aj avatar mik01aj commented on April 28, 2024

Maybe you could just use this plugin: https://github.com/gajus/babel-plugin-react-display-name

from react-docgen.

NogsMPLS avatar NogsMPLS commented on April 28, 2024

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 .createClass() convention, not for the es6 classes or stateless functional components.

I'll dig around react-docgen today and see if I can figure out a PR that might accomplish this.

from react-docgen.

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.