Skip to content

Add support for defining PropTypes using ES6 static getter #183

@bsmith-cycorp

Description

@bsmith-cycorp

With the new push for ES6 class syntax over the now-deprecated React.createClass(), this issue has become a little bit more relevant. ES6 classes don't (yet) support static data members without a MyClass.myProp = ... outside of the main class definition. They do, however, support static getters, but that would mean returning something like propTypes from a function.

For example:

class MyComponent extends React.Component {

  static get propTypes() {
    return {
      ...
    }
  }

}

vs.

class MyComponent extends React.Component {

}

MyComponent.propTypes = {
  ...
}

It's not essential, but it would be really nice to be able to declare propTypes inside the ES6 class body and still have them be detected by react-docgen.

Issue created by recommendation of @fkling in the discussion on #151

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions