Nested destructured props incorrectly cause error. #136
Closed
Description
This issue originally mentioned here: #104 (comment)
This appears to be a new issue. I had no lint errors on a previous version (sorry, I don't know exactly what version I did have, just ^2.5.2
). After upgrading to 2.6.2 (eslint version: 0.24.0)...
In .eslintrc
I have "react/prop-types": 2
My code: const {stores, section} = this.props.content;
And the propTypes:
Section.propTypes = {
content: PropTypes.shape({
section: PropTypes.object.isRequired,
stores: PropTypes.object.isRequired
})
};
Results in the error 'stores' is missing in props validation for Section react/prop-types
(and same error for section
)
If I define my propTypes like this I don't get an error, but this is not what my propTypes should look like.
Section.propTypes = {
content: PropTypes.object,
stores: PropTypes.object,
section: PropTypes.object
};
Of course if I define my consts like this I also don't get the error:
const stores = this.props.content.stores;
const section = this.props.content.section;