Comprehensive performance optimization guide for React Hook Form applications. Contains 41 rules across 8 categories, prioritized by impact to guide form development, automated refactoring, and code generation.
Integrating controlled UI components (MUI, shadcn, Ant Design)
Managing dynamic field arrays with useFieldArray
Reviewing forms for performance issues
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
Field Arrays
MEDIUM-HIGH
array-
6
State Management
MEDIUM
formstate-
7
Integration Patterns
MEDIUM
integ-
8
Advanced Patterns
LOW
adv-
Quick Reference
1. Form Configuration (CRITICAL)
formcfg-validation-mode - Use onSubmit mode for optimal performance
formcfg-revalidate-mode - Set reValidateMode to onBlur for post-submit performance
formcfg-default-values - Always provide defaultValues for form initialization
formcfg-async-default-values - Use async defaultValues for server data
formcfg-should-unregister - Enable shouldUnregister for dynamic form memory efficiency
formcfg-useeffect-dependency - Avoid useForm return object in useEffect dependencies
2. Field Subscription (CRITICAL)
sub-usewatch-over-watch - Use useWatch instead of watch for isolated re-renders
sub-watch-specific-fields - Watch specific fields instead of entire form
sub-usewatch-with-getvalues - Combine useWatch with getValues for timing safety
sub-deep-subscription - Subscribe deep in component tree where data is needed
sub-avoid-watch-in-render - Avoid calling watch() in render for one-time reads
sub-usewatch-default-value - Provide defaultValue to useWatch for initial render
sub-useformcontext-sparingly - Use useFormContext sparingly for deep nesting
3. Controlled Components (HIGH)
ctrl-usecontroller-isolation - Use useController for re-render isolation
ctrl-avoid-double-registration - Avoid double registration with useController
ctrl-controller-field-props - Wire Controller field props correctly for UI libraries
ctrl-single-usecontroller-per-component - Use single useController per component
ctrl-local-state-combination - Combine local state with useController for UI-only state
4. Validation Patterns (HIGH)
valid-resolver-caching - Define schema outside component for resolver caching
valid-dynamic-schema-factory - Use schema factory for dynamic validation
valid-error-message-strategy - Access errors via optional chaining or lodash get
valid-inline-vs-resolver - Prefer resolver over inline validation for complex rules
valid-delay-error - Use delayError to debounce rapid error display
valid-native-validation - Consider native validation for simple forms
5. Field Arrays (MEDIUM-HIGH)
array-use-field-id-as-key - Use field.id as key in useFieldArray maps
array-complete-default-objects - Provide complete default objects for field array operations
array-separate-crud-operations - Separate sequential field array operations
array-unique-fieldarray-per-name - Use single useFieldArray instance per field name
array-virtualization-formprovider - Use FormProvider for virtualized field arrays
6. State Management (MEDIUM)
formstate-destructure-formstate - Destructure formState properties before render
formstate-useformstate-isolation - Use useFormState for isolated state subscriptions
formstate-getfieldstate-for-single-field - Use getFieldState for single field state access
formstate-subscribe-to-specific-fields - Subscribe to specific field names in useFormState
formstate-avoid-isvalid-with-onsubmit - Avoid isValid with onSubmit mode for button state
7. Integration Patterns (MEDIUM)
integ-shadcn-form-import - Verify shadcn Form component import source
integ-shadcn-select-wiring - Wire shadcn Select with onValueChange instead of spread
integ-mui-controller-pattern - Use Controller for Material-UI components
integ-value-transform - Transform values at Controller level for type coercion
8. Advanced Patterns (LOW)
adv-formprovider-memo - Wrap FormProvider children with React.memo
adv-devtools-performance - Disable DevTools in production and during performance testing
adv-testing-wrapper - Create test wrapper with QueryClient and AuthProvider
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 zod skill
For React 19 server actions, see react-19 skill
For UI/UX form design, see frontend-design skill
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
1---2name: react-hook-form3description: React Hook Form Best Practices4---5# React Hook Form Best Practices67Comprehensive performance optimization guide for React Hook Form applications. Contains 41 rules across 8 categories, prioritized by impact to guide form development, automated refactoring, and code generation.89## When to Apply1011Reference these guidelines when:12- Writing new forms with React Hook Form13- Configuring useForm options (mode, defaultValues, validation)14- Subscribing to form values with watch/useWatch15- Integrating controlled UI components (MUI, shadcn, Ant Design)16- Managing dynamic field arrays with useFieldArray17- Reviewing forms for performance issues1819## Rule Categories by Priority2021| Priority | Category | Impact | Prefix |22|----------|----------|--------|--------|23| 1 | Form Configuration | CRITICAL | `formcfg-` |24| 2 | Field Subscription | CRITICAL | `sub-` |25| 3 | Controlled Components | HIGH | `ctrl-` |26| 4 | Validation Patterns | HIGH | `valid-` |27| 5 | Field Arrays | MEDIUM-HIGH | `array-` |28| 6 | State Management | MEDIUM | `formstate-` |29| 7 | Integration Patterns | MEDIUM | `integ-` |30| 8 | Advanced Patterns | LOW | `adv-` |3132## Quick Reference3334### 1. Form Configuration (CRITICAL)3536- `formcfg-validation-mode` - Use onSubmit mode for optimal performance37- `formcfg-revalidate-mode` - Set reValidateMode to onBlur for post-submit performance38- `formcfg-default-values` - Always provide defaultValues for form initialization39- `formcfg-async-default-values` - Use async defaultValues for server data40- `formcfg-should-unregister` - Enable shouldUnregister for dynamic form memory efficiency41- `formcfg-useeffect-dependency` - Avoid useForm return object in useEffect dependencies4243### 2. Field Subscription (CRITICAL)4445- `sub-usewatch-over-watch` - Use useWatch instead of watch for isolated re-renders46- `sub-watch-specific-fields` - Watch specific fields instead of entire form47- `sub-usewatch-with-getvalues` - Combine useWatch with getValues for timing safety48- `sub-deep-subscription` - Subscribe deep in component tree where data is needed49- `sub-avoid-watch-in-render` - Avoid calling watch() in render for one-time reads50- `sub-usewatch-default-value` - Provide defaultValue to useWatch for initial render51- `sub-useformcontext-sparingly` - Use useFormContext sparingly for deep nesting5253### 3. Controlled Components (HIGH)5455- `ctrl-usecontroller-isolation` - Use useController for re-render isolation56- `ctrl-avoid-double-registration` - Avoid double registration with useController57- `ctrl-controller-field-props` - Wire Controller field props correctly for UI libraries58- `ctrl-single-usecontroller-per-component` - Use single useController per component59- `ctrl-local-state-combination` - Combine local state with useController for UI-only state6061### 4. Validation Patterns (HIGH)6263- `valid-resolver-caching` - Define schema outside component for resolver caching64- `valid-dynamic-schema-factory` - Use schema factory for dynamic validation65- `valid-error-message-strategy` - Access errors via optional chaining or lodash get66- `valid-inline-vs-resolver` - Prefer resolver over inline validation for complex rules67- `valid-delay-error` - Use delayError to debounce rapid error display68- `valid-native-validation` - Consider native validation for simple forms6970### 5. Field Arrays (MEDIUM-HIGH)7172- `array-use-field-id-as-key` - Use field.id as key in useFieldArray maps73- `array-complete-default-objects` - Provide complete default objects for field array operations74- `array-separate-crud-operations` - Separate sequential field array operations75- `array-unique-fieldarray-per-name` - Use single useFieldArray instance per field name76- `array-virtualization-formprovider` - Use FormProvider for virtualized field arrays7778### 6. State Management (MEDIUM)7980- `formstate-destructure-formstate` - Destructure formState properties before render81- `formstate-useformstate-isolation` - Use useFormState for isolated state subscriptions82- `formstate-getfieldstate-for-single-field` - Use getFieldState for single field state access83- `formstate-subscribe-to-specific-fields` - Subscribe to specific field names in useFormState84- `formstate-avoid-isvalid-with-onsubmit` - Avoid isValid with onSubmit mode for button state8586### 7. Integration Patterns (MEDIUM)8788- `integ-shadcn-form-import` - Verify shadcn Form component import source89- `integ-shadcn-select-wiring` - Wire shadcn Select with onValueChange instead of spread90- `integ-mui-controller-pattern` - Use Controller for Material-UI components91- `integ-value-transform` - Transform values at Controller level for type coercion9293### 8. Advanced Patterns (LOW)9495- `adv-formprovider-memo` - Wrap FormProvider children with React.memo96- `adv-devtools-performance` - Disable DevTools in production and during performance testing97- `adv-testing-wrapper` - Create test wrapper with QueryClient and AuthProvider9899## How to Use100101Read individual reference files for detailed explanations and code examples:102103- [Section definitions](references/_sections.md) - Category structure and impact levels104- [Rule template](assets/templates/_template.md) - Template for adding new rules105- Reference files: `references/{prefix}-{slug}.md`106107## Related Skills108109- For schema validation with Zod resolver, see `zod` skill110- For React 19 server actions, see `react-19` skill111- For UI/UX form design, see `frontend-design` skill112113## Full Compiled Document114115For the complete guide with all rules expanded: `AGENTS.md`
Run npx skillmds@latest add comeonoliver/react-hook-form in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
React Hook Form Best Practices It is listed under Web & Frontend on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.