Skip to content
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

Support flow type props validation #29

Closed
ndelangen opened this issue Jul 7, 2017 · 8 comments
Closed

Support flow type props validation #29

ndelangen opened this issue Jul 7, 2017 · 8 comments

Comments

@ndelangen
Copy link
Member

Did you have any plan to support:

export default class Item extends React.Component { // eslint-disable-line
  props: {
    icon: string,
    tooltip?: string,
    onClick?: () => void,
  };

  render() {
    const { icon, tooltip, onClick } = this.props
    return (
      <span className={styles.root} onMouseDown={onClick} title={tooltip}>
        <span className="material-icons">{icon}</span>
      </span>
    )
  }
}

together with

  static propTypes = {
    icon: React.PropTypes.string.isRequired,
    tooltip: React.PropTypes.string,
    onClick: React.PropTypes.func,
  };
@danielduan
Copy link
Member

I'm not actually sure how flow works under the hood. If there's a way to get flow type transpiled in babel to static propTypes before we process the docgen stuff, there's definitely possibility.

@danielduan
Copy link
Member

Gonna close this one since it seems like react-docgen has support for flow-types in the latest versions:
https://github.com/reactjs/react-docgen

@Mottoweb
Copy link

It seems that info addon still does not render props from flow types though.

@danielduan
Copy link
Member

danielduan commented Aug 20, 2017

@Mottoweb try cleaning out your node_modules and reinstalling. You'll need the latest version of info and the associated babel plugin. It's working in the example app out of the box.

@alexeyMohnatkin
Copy link

Should it work with flow types only?

@danielduan
Copy link
Member

I'm not sure what you mean by flow types only @alexeyMohnatkin. This should work with both regular prop types and flow types.

@Mottoweb
Copy link

@danielduan it worked thanks, but still i cant see the description for the prop. Or maybe its addon-info related?

@danielduan
Copy link
Member

@Mottoweb there's been a bug fix merged to 3.3 that fixes the docgen issues when loading from static bundles.

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

No branches or pull requests

4 participants