-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Destructuring props in a stateful component triggers 'react/no-unused-prop-types' with flow in nested components #1335
Comments
Defining foo as its own type does not help. type Foo = {
bar: boolean,
};
type Props = {
foo: Foo,
}; Exact same behaviour. |
Thanks @karl-run for providing super concise repro example and also possible workarounds. The problem was that flow props ignored plugin configurations Validating shape props correctly is a whole different issue and is well known for this library. I might look into that eventually 🙂 |
Excuse the code below but it's throwing an error that is meant to be resolved in #1341 <SomeComponent
onDatesChange={
({
startDate,
endDate,
}: {
startDate: string, // error 'startDate' PropType is defined but prop is never used react/no-unused-prop-types
endDate: string, // error 'endDate' PropType is defined but prop is never used react/no-unused-prop-types
}): void => {
this.setState({ startDate, endDate });
this.datepickerChanged({
start: startDate,
end: endDate,
});
return null;
}
}
</SomeComponent>
Requesting for this issue to be re-opened- let me know if I need to give more info. |
Could you file a new issue instead? |
When accessing the props directly, through
this.props.foo.bar
it works as expected, but if I destructure fooconst { foo } = this.props
and then accessbar
through it, it is still not registered as used and will be flagged withreact/no-unused-prop-types
.Full example:
This works as expected:
The text was updated successfully, but these errors were encountered: