Skip to content

Commit

Permalink
Add docs about v1 onSubmit behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer committed Nov 21, 2019
1 parent af0c7d0 commit 430f6cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/api/formik.md
Expand Up @@ -325,7 +325,7 @@ Note: `initialValues` not available to the higher-order component, use
Your optional form reset handler. It is passed your forms `values` and the
"FormikBag".

### `onSubmit: (values: Values, formikBag: FormikBag) => void`
### `onSubmit: (values: Values, formikBag: FormikBag) => void | Promise<void>`

Your form submission handler. It is passed your forms `values` and the
"FormikBag", which includes an object containing a subset of the
Expand All @@ -336,6 +336,8 @@ passed to the wrapped component.
Note: `errors`, `touched`, `status` and all event handlers are NOT
included in the `FormikBag`.

> IMPORTANT: If `onSubmit` is async, then Formik will automatically set `isSubmitting` to `false` on your behalf once it has resolved. This means you do NOT need to call `formikBag.setSubmitting(false)` manually. However, if your `onSubmit` function is synchronous, then you need to call `setSubmitting(false)` on your own.
### `validate?: (values: Values) => FormikErrors<Values> | Promise<any>`

_Note: I suggest using `validationSchema` and Yup for validation. However,
Expand Down
4 changes: 3 additions & 1 deletion docs/api/withFormik.md
Expand Up @@ -87,7 +87,7 @@ class components (e.g. `class XXXXX extends React.Component {..}`).
Default is `false`. Control whether Formik should reset the form if the wrapped
component props change (using deep equality).

### `handleSubmit: (values: Values, formikBag: FormikBag) => void`
### `handleSubmit: (values: Values, formikBag: FormikBag) => void | Promise<void>`

Your form submission handler. It is passed your forms `values` and the
"FormikBag", which includes an object containing a subset of the
Expand All @@ -111,6 +111,8 @@ passed to the wrapped component.
Note: `errors`, `touched`, `status` and all event handlers are NOT
included in the `FormikBag`.

> IMPORTANT: If `onSubmit` is async, then Formik will automatically set `isSubmitting` to `false` on your behalf once it has resolved. This means you do NOT need to call `formikBag.setSubmitting(false)` manually. However, if your `onSubmit` function is synchronous, then you need to call `setSubmitting(false)` on your own.
### `isInitialValid?: boolean | (props: Props) => boolean`

**Deprecated in 2.x, use `mapPropsToErrors` instead**
Expand Down

0 comments on commit 430f6cc

Please sign in to comment.