Formik: isSubmitting not working

Created on 5 Apr 2020  路  3Comments  路  Source: formium/formik

I am using Formik 2.1.4 and not sure if this is a bug or not but I am trying to use isSubmitting in an async function but it doesn't seem to work for me. According to what I saw in the docs you don't need to use set setSubmitting on submit like:

onSubmit={async (values, { setSubmitting }) => {

<Formik

// initial values
// validation Schema

onSubmit={async (values) => {
// http request here
>

{(formik, isSubmitting) => (
<Form>
// inputs
<Button
  type="submit"
  disabled={isSubmitting}
>
  {isSubmitting ? `Submiting...` : `Submit`}
</Button>
 </Form>
</Formik>

The button does not disable on submit nor does the button label text change.

Most helpful comment

In your example above, it should be formik.isSubmitting and you can remove the second arg to your child fn.

All 3 comments

In your example above, it should be formik.isSubmitting and you can remove the second arg to your child fn.

Ahah! Brilliant, thanks.

no problem!

Was this page helpful?
0 / 5 - 0 ratings