import React from 'react';
2 import { useFormik } from 'formik';
3
4 const 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: {
name: '',
9 email: '',
10 },
11 onSubmit: values => console.log(values),
14 });
15 return (
16 <form onSubmit={formik.handleSubmit}>
17 <label htmlFor="name">Name</label>
18 <input
19 id="name"
20 name="name"
21 type="name"
22 onChange={formik.handleChange}
23 value={formik.values.name}
24 />
<label htmlFor="email">Email Address</label>
18 <input
19 id="email"
20 name="email"
21 type="email"
22 onChange={formik.handleChange}
23 value={formik.values.email}
24 />
25
26 <button type="submit">Submit</button>
27 </form>
28 );
29 };