react-hook-form
pproenca/dot-skills
React Hook Form performance optimization guide with 35 best-practice rules across form configuration, subscriptions, and validation.
What is react-hook-form?
Comprehensive reference for building performant client-side forms with React Hook Form (v7.82+). Covers useForm configuration, field subscriptions, controlled components, validation patterns, state management, field arrays, and UI library integration. Use this when optimizing form performance or integrating RHF with component libraries like MUI, shadcn, or Ant Design.
- Provides 35 decision-focused rules organized by priority (form config, subscriptions, controlled components, validation, state management, field arrays, integrations)
- Guides useForm option configuration (mode, defaultValues, validation, reValidateMode, shouldUnregister)
- Explains field subscription patterns (watch vs useWatch vs subscribe, render-prop components, FormProvider context)
- Documents controlled component integration with useController and UI libraries (shadcn, MUI, Ant Design)
- Covers validation patterns including resolver caching, server errors, and async handling
- Details useFieldArray best practices including disabled option, CRUD operations, and key selection
How to install react-hook-form
npx skills add https://github.com/pproenca/dot-skills --skill react-hook-form- React Hook Form v7.82.0 or later installed
- Familiarity with React hooks (useEffect, useContext, useCallback)
- Understanding of controlled vs uncontrolled form components
How to use react-hook-form
- 1.Review the Rule Categories by Priority table to identify which categories apply to your form needs
- 2.Read the relevant reference files (formcfg-*, sub-*, ctrl-*, valid-*, formstate-*, array-*, integ-*) for detailed explanations and code examples
- 3.Apply rules to your useForm configuration, field subscriptions, and component integration patterns
- 4.Reference the AGENTS.md compiled document for complete rule details with all examples
- 5.Check Related Skills section for complementary guidance (zod for schema validation, react-19 for server actions)
Use cases
- Optimizing form re-renders in large forms with many fields by using useWatch and render-prop components instead of watch()
- Integrating shadcn or MUI form components with React Hook Form using useController and proper field wiring
- Managing dynamic field arrays with proper key selection and handling the disabled option behavior
- Surfacing server-side validation errors via setError and handling async submit lifecycle
- Configuring useForm with async defaultValues for forms initialized from server data
- React developers building forms with React Hook Form library
- Frontend engineers optimizing form performance in large applications
- Developers integrating RHF with UI component libraries (shadcn, MUI, Ant Design)
- Teams standardizing form patterns and best practices across codebases
react-hook-form FAQ
Use useWatch() instead of watch() for isolated re-renders in child components. Avoid calling watch() in render for one-time reads; use useWatch or the Watch render-prop component instead.
React.memo cannot stop context-driven re-renders under FormProvider. Instead, isolate subscriptions using useWatch, useFormState, or render-prop components (Watch, FormStateSubscribe, FieldArray) in dedicated child components.
Use useController to wrap the component and wire the field props correctly. For shadcn Select, use onValueChange instead of spreading field props. For MUI components, ensure value and onChange are properly connected.
Surface server errors via setError('root.serverError', {message: 'error text'}) after an async submit fails. Use handleSubmit's second argument (onInvalid) to handle rejected submissions.
The disabled option makes every mutation (append, remove, insert, swap) a silent no-op. Use the HTML disabled attribute on individual fields instead if you need visual disabling without removing from the payload.
Full instructions (SKILL.md)
Source of truth, from pproenca/dot-skills.
name: react-hook-form description: React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, useFieldArray, the subscribe() API, and the Watch / FormStateSubscribe / FieldArray render-prop components. Covers RHF 7.82 additions including resetDefaultValues() and the disabled field-array option. This skill should be used when building client-side controlled forms with React Hook Form library. This skill does NOT cover React 19 Server Actions, useActionState, or server-side form handling (use react-19 skill for those).
React Hook Form Best Practices by Community
Comprehensive performance optimization guide for React Hook Form applications. Contains 35 rules across 7 categories, each naming a decision that goes wrong by default. Verified against react-hook-form 7.82.0.
When to Apply
Reference these guidelines when:
- Writing new forms with React Hook Form
- Configuring useForm options (mode, defaultValues, validation)
- Subscribing to form values with watch / useWatch / subscribe
- Integrating controlled UI components (MUI, shadcn, Ant Design)
- Managing dynamic field arrays with useFieldArray
- Handling async submit, server errors, and submit lifecycle state
- Reviewing forms for performance issues
When NOT to Use This Skill
- React 19 Server Actions /
useActionState— use thereact-19skill instead - Deeply nested, fully type-safe forms — TanStack Form may be a better fit for forms with complex nested schemas; this skill assumes you've already chosen RHF
- Single-input or trivial forms — uncontrolled
<form>+FormDatais often simpler than pulling in any library
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Form Configuration | CRITICAL | formcfg- |
| 2 | Field Subscription | CRITICAL | sub- |
| 3 | Controlled Components | HIGH | ctrl- |
| 4 | Validation Patterns | HIGH | valid- |
| 5 | State Management | MEDIUM-HIGH | formstate- |
| 6 | Field Arrays | MEDIUM-HIGH | array- |
| 7 | Integration Patterns | MEDIUM | integ- |
Quick Reference
1. Form Configuration (CRITICAL)
formcfg-default-values- Always Provide defaultValues for Form Initializationformcfg-useeffect-dependency- Depend on formState Slices, Not on formState Itselfformcfg-validation-mode- Justify Any mode Other Than the Default onSubmitformcfg-revalidate-mode- Keep Default reValidateMode Unless Validation Is Expensiveformcfg-should-unregister- Keep shouldUnregister Off Unless Hidden Fields Must Leave the Payloadformcfg-transformed-values-generic- Pass the Third useForm Generic When the Resolver Transforms Valuesformcfg-async-default-values- Use Async defaultValues for Server Dataformcfg-disabled-prop- Use the HTML disabled Attribute for Visual Disabling, Not register's disabled Optionformcfg-values-prop- Use the values Prop to Keep a Form in Sync with Server Data
2. Field Subscription (CRITICAL)
sub-avoid-watch-in-render- Avoid Calling watch() in Render for One-Time Readssub-memo-cannot-beat-context- React.memo Cannot Stop Context-Driven Re-renders Under FormProvidersub-subscribe-outside-react- Use subscribe() to React to Form Changes Outside the React Lifecyclesub-render-prop-components- Use the Render-Prop Components to Isolate Re-renders Without a Child Componentsub-useformcontext-sparingly- Use useFormContext Sparingly for Deep Nestingsub-usewatch-over-watch- Use useWatch Instead of watch for Isolated Re-renderssub-watch-specific-fields- Watch Specific Fields Instead of Entire Form
3. Controlled Components (HIGH)
ctrl-usecontroller-isolation- Isolate Controlled Inputs in Dedicated Child Componentsctrl-controller-field-props- Wire Controller Field Props Correctly for UI Libraries
4. Validation Patterns (HIGH)
valid-resolver-caching- Build the Validation Schema Once, Outside the Render Pathvalid-valueasnumber-empty-nan- Handle the NaN valueAsNumber Produces for an Empty Inputvalid-server-errors- Surface Server Errors via setError('root.serverError', ...)valid-delay-error- Use delayError to Debounce Rapid Error Display
5. State Management (MEDIUM-HIGH)
formstate-avoid-isvalid-with-onsubmit- Avoid isValid with onSubmit Mode for Button Stateformstate-destructure-formstate- Read Every formState Property You Depend On During Renderformstate-reset-default-values- Rebase Defaults with resetDefaultValues After a Successful Saveformstate-handlesubmit-oninvalid- Use handleSubmit's Second Argument to Handle a Rejected Submitformstate-useformstate-isolation- Use useFormState for Isolated State Subscriptionsformstate-async-submit-lifecycle- Wrap Async Submit Handlers in try/catch and Reset on isSubmitSuccessful
6. Field Arrays (MEDIUM-HIGH)
array-separate-crud-operations- Separate Sequential Field Array Operationsarray-use-field-id-as-key- Use field.id as Key in useFieldArray Mapsarray-unique-fieldarray-per-name- Use Single useFieldArray Instance Per Field Namearray-disabled-silently-noops- useFieldArray's disabled Option Makes Every Mutation a Silent No-op
7. Integration Patterns (MEDIUM)
integ-value-transform- Transform Values at Controller Level for Type Coercioninteg-shadcn-form-import- Verify shadcn Form Component Import Sourceinteg-shadcn-select-wiring- Wire shadcn Select with onValueChange Instead of Spread
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
- Reference files:
references/{prefix}-{slug}.md
Related Skills
- For schema validation with Zod resolver, see
zodskill - For React 19 server actions, see
react-19skill - For UI/UX form design, see
frontend-designskill
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
Related skills
More from pproenca/dot-skills and the wider catalog.

react-refactor
Architectural refactoring guide for React applications covering component architecture, state architecture, hook patterns, component decomposition, coupling and cohesion, data flow, and refactoring safety. Use when refactoring React codebases, reviewing PRs for architectural issues, decomposing oversized components, or improving module boundaries. Does NOT cover React 19 API usage (see react skill) or performance optimization (see react-optimise skill).

shadcn
shadcn/ui component library best practices and patterns (formerly shadcn-ui). This skill should be used when writing, reviewing, or refactoring shadcn/ui components to ensure proper architecture, accessibility, and performance. Triggers on tasks involving Radix primitives, Tailwind styling, form validation with React Hook Form, data tables, theming, or component composition patterns.

terminal-ui
Terminal User Interface (TUI) performance and UX guidelines for TypeScript applications using Ink and Clack. This skill should be used when building CLI tools, interactive terminal prompts, or developer tooling with TUI components. Triggers on tasks involving TUI components, CLI prompts, terminal rendering, keyboard input handling, or developer tooling.

typescript
TypeScript performance, tsconfig, type errors, and async patterns optimization.

ui-design
UI/UX and frontend design best practices guidelines (formerly frontend-design). This skill should be used when writing, reviewing, or designing frontend code to ensure accessibility, performance, and usability. Triggers on tasks involving HTML structure, CSS styling, responsive layouts, form design, animations, or accessibility improvements.

vitest
Vitest testing framework patterns: async, mocking, setup, snapshots, and performance optimization.