React useForm

Chay Auker
Sep 24, 2021

--

I recently learned React useForm and wanted to provide you with some information about how it works.

  1. Import React from ‘react’; import { useForm } from ‘react-hook-form’ as follows:

2. Create a variable and set it to useForm(), each object key will register as an input. Create variable name value for data that user inputs;

3. Create an input form for the user to fill in their information and make sure default values should be empty objects.

4. Pass onSubmit function to handleSubmit. Then set value to data was passed by the call back function. Finally, this form should work.

Resources

--

--