-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
Description
Hello!
Got an strange behavior when assign this.props to props, it will throw an error message is missing in props validation.
And seems it only happens when use const props = this.props.
eslint: 4.0.0
eslint-plugin-react: 7.1.0
This piece of code will throw an error.
const Card = React.createClass({
propTypes: {
isReturning: PropTypes.bool,
date: PropTypes.string
},
render() {
const props = this.props;
return (
<div>
{props.isReturning}
{props.departureDate}
</div>
)
}
});error 'isReturning' is missing in props validation react/prop-types
error 'departureDate' is missing in props validation react/prop-typesThis is no error.
const Card = React.createClass({
propTypes: {
isReturning: PropTypes.bool,
date: PropTypes.string
},
render() {
const {isReturning, departureDate} = this.props;
return (
<div>
{isReturning}
{departureDate}
</div>
)
}
});This is no error.
const Card = React.createClass({
propTypes: {
isReturning: PropTypes.bool,
date: PropTypes.string
},
render() {
return (
<div>
{this.props.isReturning}
{this.props.departureDate}
</div>
)
}
});Even this is no error.
const Card = React.createClass({
propTypes: {
isReturning: PropTypes.bool,
date: PropTypes.string
},
render() {
const test = this.props;
return (
<div>
{test.isReturning}
{test.departureDate}
</div>
)
}
});imfeng, supfiger and alexander-elgin