Formik: `onSubmit` handler not being called

Created on 7 Aug 2019  路  2Comments  路  Source: formium/formik

馃悰 Bug report

Current Behavior

On form submission onSubmit is not being called in

Expected behavior

onSubmit should be called with the form values

Reproducible example

Codesandbox link:
Formik template: https://codesandbox.io/s/cocky-mcnulty-dyx26

Suggested solution(s)

I don't know why onSubmit is not being called.

Additional context

Your environment

| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 1.5.8
| React | 16.8.6
| TypeScript | 3.5.3
| Browser | chrome
| npm/Yarn | 6.9.0/1.17.0
| Operating System | macOS Mojave

Most helpful comment

Found the issue. onSubmit will be called if the form is valid. I wasn't entering a valid email.

All 2 comments

You're missing an inner <form> element and handleSubmit should be attached to that form element, not the submit button.

Also your onChange handlers should be simplified to onChange={handleChange}

See https://jaredpalmer.com/formik/docs/overview#the-gist

Found the issue. onSubmit will be called if the form is valid. I wasn't entering a valid email.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dearcodes picture dearcodes  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

outaTiME picture outaTiME  路  3Comments

ancashoria picture ancashoria  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments