0

I am using the following code snippet for validation in my form using formik:

{props => {
  const {
    values: { email, password },
    errors,
    touched,
    handleChange,
    isValid,
    setFieldTouched,
  } = props;
  const change = (name: string, e: any) => {
    e.persist();
    handleChange(e);
    setFieldTouched(name, true, false);
  };

Instead of e:any, I want to specify a data type. Isn't e an event? When I put event instead of any, I get an erorr that:

Property 'persist' does not exist on type 'Event'.  TS2339

What else should I use then?

2 Answers2

0

A similar question was asked previously, check this out maybe it helps.

Typescript: React event types

  • Hey, for things that are already answered, this type of post is better as a comment to the question. Or you could also flag as a `Dulicate` and provide a link withing Stackoverflow to the same answered question. – Andrew Nolan Mar 24 '20 at 15:30
0

e: FormEvent works since the event is being used for a form.