Understanding "PropType is defined but prop is not never used" + Formik
See original GitHub issueHello all!
I am making a Formik form and ESLint was complaining about some props missing validation. Then, I added propTypes and defaults and I got the error “PropType is defined but prop is never used”.
I believe this error is due to the fact that when I place MyComponent.propTypes blabla I was assigning props to my functional components. However, ESLint complains about the props passed to the render prop function. An example of such props are errors and touched from the function ValidationSchemaExample on https://jaredpalmer.com/formik/docs/guides/validation
In my personal code I had something like this:
const renderResetPasswordRequestForm = ({ errors, touched, handleSubmit } ) => {
return (
<form onSubmit={handleSubmit}>
</form>
);
};
Which was triggering the error, however, with the below code it does not happen:
const renderResetPasswordRequestForm = formikProps => {
const { errors, touched, handleSubmit } = formikProps;
return (
<form onSubmit={handleSubmit}>
</form>
);
};
So the key question: Anyone understand why if I destructure the parameters it complains and if I do so in the body of the function ESLint does not complain?
Thank you in advance and regards.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Related StackOverflow Question
I just tested this issue with the changes in #2699 and since functions not starting with an uppercase letter are not considered components the error about props not being defined on render props it not triggered.
The bug seems to be that the variable name must be named
props: