Skip to content

Conversation

@phpnode
Copy link
Contributor

@phpnode phpnode commented Jan 5, 2016

This PR adds support for using flow type annotations for class props instead of propTypes. Flow added support for this quite recently in: facebook/flow#850

The syntax looks like this:

type Person = {
  name: {
    firstName: string;
    lastName: string;
  },
  age: number;
};
type Props = {
  greeting: string;
  people: Person[];
};
class Hello extends React.Component {
  props: Props;

  render () {
    const names = [];
    for (let i = 0; i < this.props.people.length; i++) {
      names.push(this.props.people[i].name.firstName);
    }
    return <div>{this.props.greeting}, {names.join(', ')}</div>;
  }
}

@yannickcr
Copy link
Member

Wow! This is really great!

Can you squash your commits ? Then I think we'll be good to go :)

@phpnode phpnode force-pushed the support-props-annotations branch from 5529f71 to b8e0a4e Compare January 7, 2016 00:25
@phpnode
Copy link
Contributor Author

phpnode commented Jan 7, 2016

@yannickcr squashed

yannickcr added a commit that referenced this pull request Jan 7, 2016
Add support for flow annotations in prop-types
@yannickcr yannickcr merged commit a929545 into jsx-eslint:master Jan 7, 2016
@yannickcr
Copy link
Member

Merged, thanks!

@phpnode
Copy link
Contributor Author

phpnode commented Jan 7, 2016

awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants