Untitled
unknown
javascript
3 years ago
625 B
9
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...