Destructuring props in a stateful component triggers 'react/no-unused-prop-types' with flow in nested components #1335
Closed
Description
opened on Jul 31, 2017
When accessing the props directly, through this.props.foo.bar
it works as expected, but if I destructure foo const { foo } = this.props
and then access bar
through it, it is still not registered as used and will be flagged with react/no-unused-prop-types
.
Full example:
type Props = {
foo: {
bar: boolean, // error 'foo.bar' PropType is defined but prop is never used
},
};
class DigitalServices extends React.Component {
props: Props
render() {
const { foo } = this.props;
return <div>{foo.bar}</div>;
}
}
This works as expected:
class DigitalServices extends React.Component {
props: Props
render() {
return <div>{this.props.foo.bar}</div>;
}
}
Activity