jaredpalmer / formik

Build forms in React, without the tears 😭
https://formik.org
Apache License 2.0
33.87k stars 2.79k forks source link

Eslint prop missing validation with Formik #2018

Open javierguzman opened 4 years ago

javierguzman commented 4 years ago

Hello all!

I am using Formik in my project and now I have started using Eslint. I am getting a bunch of messages saying stuff like for example, "values is missing in props validation" or "errors is missing in props validation".

These are Formik props and I would have thought I do not need to validate them manually.

If I do PropTypes.array or PropTypes.object then I get another ESLint error (e.g. "Prop type array is forbidden").

Is normal to get these errors? What is the best way to avoid them without disabling the Eslint rule?

Thank you in advance and regards.

javierguzman commented 4 years ago

I have managed to get the error "PropType is defined but prop is not never used". I think this is because the propTypes I am defining are my functional component props. However, the "real" ones are the ones passed to the Formik render prop function. edit: I have fixed it...with this I get ESLint errors:

  const renderResetPasswordRequestForm = ({ errors, touched, handleSubmit } ) => {
    return (
      <form onSubmit={handleSubmit}>
      </form>
    );
  };

With this there are no errors:

const renderResetPasswordRequestForm = formikProps => {
    const { errors, touched, handleSubmit } = formikProps;
    return (
      <form onSubmit={handleSubmit}>
      </form>
    );
  };

Does anyone know why is this?

jfzhou90 commented 4 years ago

I'm running into this issue to, how can i add a proptype to formik props?

Alamin02 commented 3 years ago

Running into the same issue here.