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

Using a prop as an object key to call a function, incorrectly reports missing in props validation #132

Closed
Standard8 opened this issue Jun 28, 2015 · 2 comments

Comments

@Standard8
Copy link

Testcase:

var TestComp1 = React.createClass({
  propTypes: {
    size: React.PropTypes.string.isRequired
  },

  render: function() {
    var foo = {
      "abc": ["1", "2", "3"]
    };

    var icons = foo[this.props.size].map(function() {
      return null;
    });
    return (<div>{icons}</div>);
  }
});

Output:

  11:37  error  'size[].map' is missing in props validation  react/prop-types

 1 problem (1 error, 0 warnings)

this.props.size is being used as the key for the object, not as an object itself.

@Standard8
Copy link
Author

Forgot to say, this is a regression in 2.6.0.

@yannickcr
Copy link
Member

It should come from the new nested props support. I will investigate.

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