title: Formik errors object is not being updated properly on input
body: <p>coming into a new codebase here and it's also my first time using Formik and Yup so I will try to be as concise as possible, but bear with me.</p>
  <p>I have some forms that were built with Formik and use a validation schema provided by Yup. I also have a useState variable to indicate whether or not an item is present in Yup's <code>errors</code> object that is used to prevent the user from continuing to the next form until the error is fixed. The validation works correctly initially, as when an invalid input is provided, the corresponding error is shown in the <code>errors</code> object. However, if I type something valid into the field and then go back and change it so that it's invalid, the <code>errors</code> object doesn't update to reflect that new error until the next input event, which throws off the value of the state variable checking it. A basic example:</p>
  <p>Enter Email: testgmail.com ---&gt; <code>errors</code>: <code>{email: &quot;Invalid email&quot;}</code></p>
  <p>Enter Email: test@gmail.com ---&gt; <code>errors</code>: <code>{}</code></p>
  <p>Enter Email: test@gmail ---&gt; <code>errors</code>: <code>{}</code></p>
  <p>It's not until I trigger the next input that <code>errors</code> populates back to <code>{email: &quot;Invalid email&quot;}</code>.</p>
  <p>Any idea how to fix this problem? I will try to supply some cleaned up code below, but again apologies as it's a brand new codebase to me so I'm not sure how useful it will be.</p>
  <pre><code>const validate = Yup.object().shape({
      name: Yup.string().required(&quot;This field is required&quot;),
      email: Yup.string()
        .email(&quot;Invalid email format&quot;)
        .required(&quot;Your email is required&quot;),
      code: Yup.string().required(&quot;This field is required&quot;),
    });
  
  function handleInputChange(e: any, errors: FormikErrors, errorSetter: any, codeSetter: any, codeInfo: any) {
      codeSetter({ ...codeInfo, [e.target.name]: e.target.value });
      if (Object.keys(errors).length &gt; 0) {
        errorSetter(true);
      }
      else errorSetter(false)
    }
  
  &lt;Formik
              initialValues={{
                name: codeInfo.name,
                email: codeInfo.email,
                code: codeInfo.code,
              }}
              onSubmit={() =&gt; {}}
              validationSchema={validate}
            &gt;
              {({
                handleSubmit,
                handleChange,
                values,
                errors,
                touched,
                handleBlur,
              }) =&gt; (
                &lt;form className={styles.form} onSubmit={handleSubmit}&gt;
                  &lt;div className={styles.formTextfields}&gt;
                    &lt;div className={styles.textfields}&gt;
                      &lt;span className={styles.tag}&gt;Email*&lt;/span&gt;
                      &lt;TextField
                        name=&quot;email&quot;
                        value={values.email}
                        placeholder=&quot;test@gmail.com&quot;
                        onChange={handleChange}
                        onBlur={handleBlur}
                        onInput={(e: any) =&gt; handleInputChange(e, errors)}
                        variant={
                          errors.email &amp;&amp; touched.email ? &quot;error&quot; : &quot;focus&quot;
                        }
                      /&gt;
                      {errors.email &amp;&amp; touched.email ? (
                        &lt;div className={styles.error}&gt;{errors.email}&lt;/div&gt;
                      ) : null}
                    &lt;/div&gt;
                &lt;/form&gt;
              )}
  &lt;/Formik&gt;
  </code></pre>