Untitled
unknown
javascript
2 years ago
625 B
6
Indexable
import { Formik, Form, Field } from 'formik'; const validate = (value) => { let error; if (!value) { error = 'Required'; } return error; } const MyForm = () => ( <Formik initialValues={{ inputValue: '' }} onSubmit={(values, { setSubmitting }) => { setTimeout(() => { alert(JSON.stringify(values, null, 2)); setSubmitting(false); }, 400); }} > {({ isSubmitting }) => ( <Form> <Field name="inputValue" validate={validate} /> <button type="submit" disabled={isSubmitting}> Submit </button> </Form> )} </Formik> );
Editor is loading...