Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
Formik `isSubmitting` and `isValidating` are `false` during pre-submit validation

I'm submitting a form using Formik. I want to have slightly different validation logic depending on whether it's being triggered by blur/change events or pre-submit validation. (Long story short, during pre-submit, I only want to run sync validation — my back end will do the same async validation that I run on blur/change when I submit the form, so I want to skip it in pre-submit.) My validate function looks something like this:

  validate={(value) => {
    const error = validateSync(value);
    if (!error && !form.isSubmitting) {
      return validateAsync(value);
    }
    return error;
  }}

In this case, I'm using useFormikContext to get form.isSubmitting.

According to the Formik docs on submission, isSubmitting should be set to true immediately in the Pre-submit stage, before the Validation stage. This doesn't seem to be happening, as you can see if you try to submit the form in this sandbox (check the console to see that both isSubmitting and isValidating are false — according to the Formik docs, they should both be true at this stage).

Another user had a similar question, but the answer doesn't address the underlying (possible) bug with Formik.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Used React's useRef hook to reference the current version of the form:

const form = useFormikContext();
const formRef = useRef();
formRef.current = form;

// within a delayed callback:
function delayedCallback() {
  // pulls the current value of isSubmitting, whenever the delayedCallback fires
  const { isSubmitting } = formRef.current;
};

Works 100%

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!