React Hook Form Library
github.com
2
Leaving SiteNav
External Link Disclaimer
You are about to visit github.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
React Hook Form is a free and open-source, performant, flexible, and extensible React hooks-based form library. Created by Bill Luo (bluebill1049) in 2019, React Hook Form has become one of the most popular React form libraries, known for its excellent performance and minimal re-renders. Used by over 2 million projects. Key features: performance: React Hook Form uses uncontrolled components and refs, avoiding the re-render storm of controlled form inputs. Form state updates do not trigger component re-renders, resulting in significantly faster forms compared to Formik or controlled-input approaches. useForm hook: the central API. useForm({ defaultValues, resolver, mode }) returns register, handleSubmit, watch, setValue, getValues, reset, formState, and other functions. register: registers input fields with the form by spreading register('fieldName') onto input elements. This binds the input to the form state without re-renders. Validation: built-in validation rules (required, min, max, minLength, maxLength, pattern) via the register options. Custom async validation supported. Schema validation via resolvers: integrates with Yup, Zod, Joi, and Vest for schema-based validation via the resolver option. handleSubmit: wraps the form submission, running validation and only calling the onSubmit callback if validation passes. formState: provides errors, isDirty, isValid, isSubmitting, touchedFields, and dirtyFields without triggering re-renders. watch: subscribe to field value changes. Controller: for integrating controlled components (React Select, Material UI inputs, MUI) that require controlled value/onChange. useFieldArray: manage dynamic field arrays (repeating form sections). useWatch: subscribe to specific field changes without re-rendering the entire form. TypeScript-first. JavaScript/TypeScript. MIT.
Statistics
2
Views
0
Clicks
0
Like
0
Dislike