Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Just a gist to explain React Hook Form (RHF)
export default function DeliveryForm() {
const { register, handleSubmit, formState: { errors } } = useForm();
const onSubmit = data => console.log(data);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input placeholder="Full Name" {...register("fullName")} />
<input placeholder="Delivery Address" {...register("deliveryAddress", { required: true })} />
{errors.deliveryAddress && <span>Delivery Address is required</span>}
<button type="submit">Review Order</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment