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

prop-types warns even if you don’t use props at all #4

Closed
lo1tuma opened this issue Feb 24, 2015 · 1 comment
Closed

prop-types warns even if you don’t use props at all #4

lo1tuma opened this issue Feb 24, 2015 · 1 comment
Assignees

Comments

@lo1tuma
Copy link

lo1tuma commented Feb 24, 2015

The prop-types rule warns always if you don’t specify the propTypes property within a react component even if you don’t use any props.

I suggest to only warn if a used prop is not defined within propTypes. This would also be good if you have specified the propTypes property somehow but not defined every used prop.

So the following should not be considered as a warning:

var Hello = React.createClass({
  render: function() {
    return <div>Hello World</div>;
  }
});

But this should be considered as a warning:

var Hello = React.createClass({
  propTypes: {
    name: React.PropTypes.string.isRequired
  },
  render: function() {
    return <div>Hello {this.props.name} and {this.props.propWithoutTypeDefinition}</div>;
  }
});
@yannickcr
Copy link
Member

You are right, warn only if a used prop is not defined within propTypes seems to be the way to go.

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

No branches or pull requests

2 participants