Skip to content

Commit

Permalink
Add example usage of the second parameter of the onSubmit method. (#1305
Browse files Browse the repository at this point in the history
)

* Add example of second onSubmit method parameter.

More docs = more knowledge!

Closes: #1107

Related: #234

* Update docs/guides/typescript.md

LGTM

Co-Authored-By: beausmith <beau@beausmith.com>
  • Loading branch information
beausmith authored and jaredpalmer committed Feb 6, 2019
1 parent 02b8911 commit 7e42ed7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/guides/typescript.md
Expand Up @@ -14,7 +14,7 @@ similar to React Router 4's `<Route>`.

```typescript
import * as React from 'react';
import { Formik, FormikProps, Form, Field, FieldProps } from 'formik';
import { Formik, FormikActions, FormikProps, Form, Field, FieldProps } from 'formik';

interface MyFormValues {
firstName: string;
Expand All @@ -26,7 +26,11 @@ export const MyApp: React.SFC<{}> = () => {
<h1>My Example</h1>
<Formik
initialValues={{ firstName: '' }}
onSubmit={(values: MyFormValues) => alert(JSON.stringify(values))}
onSubmit={(values: MyFormValues, actions: FormikActions<MyFormValues>) => {
console.log({ values, actions });
alert(JSON.stringify(values, null, 2));
actions.setSubmitting(false)
}}
render={(formikBag: FormikProps<MyFormValues>) => (
<Form>
<Field
Expand Down

0 comments on commit 7e42ed7

Please sign in to comment.