Forms are where React apps quietly get slow. The classic approach stores every keystroke in state, which re-renders the whole form on every character typed. React Hook Form takes a different path: it reads values from uncontrolled inputs, so your component barely re-renders at all.
Getting started takes minutes:
import { useForm } from 'react-hook-form';
function SignupForm() {
const { register, handleSubmit, formState: { errors } } = useForm();
const onSubmit = (data) => console.log(data);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input {...register('email', { required: 'Email is required' })} />
{errors.email && <p>{errors.email.message}</p>}
<input
type="password"
{...register('password', { required: true, minLength: 8 })}
/>
{errors.password && <p>Password must be at least 8 characters.</p>}
<button type="submit">Sign up</button>
</form>
);
}
The register function connects each input to the form. Validation rules like required and minLength live right next to the field, and errors appear in formState.errors without any extra code.
This approach has two big wins. First, performance: typing in one field does not re-render the others, which matters a lot in long forms. Second, less code: no value and onChange handler for every single input.
React Hook Form also plays well with validation libraries like Zod and Yup, so you can define one schema and use it on the client and the server. It works with UI libraries too — there are wrappers for controlled components like date pickers and rich text editors.
React Hook Form is for anyone building signup forms, checkout forms, settings pages, or admin panels in React. If your forms have more than three fields, it will save you real code and real re-renders.
Top comments (0)