1import React from 'react';
2import { useFormik } from 'formik';
3
4const SignupForm = () => {
5 // Pass the useFormik() hook initial form values and a submit function that will
6 // be called when the form is submitted
7 const formik = useFormik({
8 initialValues: {
9 email: '',
10 },
11 onSubmit: values => {
12 alert(JSON.stringify(values, null, 2));
13 },
14 });
15 return (
16 <form onSubmit={formik.handleSubmit}>
17 <label htmlFor="email">Email Address</label>
18 <input19 id="email"
19 name="email"
20 type="email"
21 onChange={formik.handleChange}
22 value={formik.values.email}
23 />
24
25 <button type="submit">Submit</button>
26 </form>
27 );
28 };