24
loading...
This website collects cookies to deliver better user experience
Want the ultimate guide to become a 6-figure React developer? Check out The React Bootcamp.
useClipboard
) from Chakra UI that allows us to copy text to our users’ clipboard.useFormik
which allows us to build our forms with the help of a custom hook of the same name.useFormik
.import React from 'react';
import { useFormik } from 'formik';
const SignupForm = () => {
const formik = useFormik({
initialValues: {
username: '',
email: '',
},
onSubmit: values => {
alert(JSON.stringify(values, null, 2));
},
});
return (
<form onSubmit={formik.handleSubmit}>
<label htmlFor="name">Username</label>
<input
id="username"
name="username"
type="text"
onChange={formik.handleChange}
value={formik.values.username}
/>
<label htmlFor="email">Email Address</label>
<input
id="email"
name="email"
type="email"
onChange={formik.handleChange}
value={formik.values.email}
/>
<button type="submit">Submit</button>
</form>
);
};