- 'react-hook-form' is a library that helps you validate forms in React.
- The package size is tiny (just 8.6 kB minified and gzipped) and it has zero dependencies.
- If npm: npm install react-hook-form
- If yarn: yarn add react-hook-form
- import the useForm Hook from the react-hook-form package:
import { useForm } from "react-hook-form";
- The useForm Hook returns an object containing a few properties like: register, handlesubmit..etc
- useForm Hook makes the component code cleaner and easier to maintain, and because the form is uncontrolled, you do not have to pass props like onChange and value to each input.
- To apply validation to input fields we can pass validation parameters to the register
This project was bootstrapped with Create React App. In the project directory:
Please refer: https://github.com/Prashika/react-hook-form-repo.git
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in your browser.
The page will reload when you make changes.
You may also see any lint errors in the console.