I am using Formik and overriding their render method to get some extra control over my component. I've used it before in another project, but in a new project, I am getting errors about missing prop types... but this is a Formik component, which has complete control over its own props, and I don't want to write prop types for it.
I would rather not just disable ESLint on the line, as that is hacky and ugly.
Example:
<Formik
// other props ...
render={(props) => {
const { exampleFormikProp } = props;
// I then use that prop in things
}
/>
Problem: ESLint wants exampleFormikProp in props validation. It never complained about this in my old app. To me, this feels like an error. I shouldn't have to prop type something that Formik controls, I have no way of changing what Formik gives me here.
The only remotely related ESLint rules I have:
'react/forbid-prop-types': 0,
'react/require-default-props': 0,
'react/jsx-props-no-spreading': 0,
None of those seem relevant. I haven't been able to find any other example. This question seems like it could be related but has no answer.
How do I fix this?
To be clear, I want prop types to be required on components that I am creating, but I don't want them when overriding render in this method, as I don't think it's appropriate.
Example:
function MyComponent(props) {
// I -want- to require prop-types for these props
const { myCustomProps } = props;
return (
<Formik
// I -don't- want to define prop-types for these, as that is inappropriate
render={props => {...}}
/>
);
}
Update 10/1/19 - A temporary workaround seems to be renaming props to formikProps or some other term. I don't really like it, but it works. I'd still like an answer to the underlying problem, however.