Closed
Description
In this code, I think the _renderValue
method is being treated as a stateless functional component, and the prop-types rule is complaining about the value
parameter:
const MyComponent = React.createClass({
propTypes: {
values: React.PropTypes.arrayOf(React.PropTypes.number.isRequired).isRequired,
},
_renderValue({value}) { // Error: 'value' is missing in props validation (react/prop-types)
return <span>{value}</span>;
},
render() {
return (
<div>
{this.props.values.map((value) => this._renderValue({value}))}
</div>
);
},
});
Note that this only seems to happen when there are destructured params and only when using React.createClass
, not ES2015 classes. It seems like a reasonable fix (if I'm interpreting the problem correctly) would be to say that a function isn't an SFC if it's defined using method syntax.
Metadata
Metadata
Assignees
Labels
No labels