React hook form
Skill Pythoughts-labs/react-frontend-skills/skills/react-hook-form
React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, and useFieldArray. 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).From its SKILL.md
npx -y skills add Pythoughts-labs/react-frontend-skills --skill react-hook-formAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.6 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it
React Hook Form Best Practices
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.
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
- 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 performanceformcfg-revalidate-mode- Set reValidateMode to onBlur for post-submit performanceformcfg-default-values- Always provide defaultValues for form initializationformcfg-async-default-values- Use async defaultValues for server dataformcfg-should-unregister- Enable shouldUnregister for dynamic form memory efficiencyformcfg-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-renderssub-watch-specific-fields- Watch specific fields instead of entire formsub-usewatch-with-getvalues- Combine useWatch with getValues for timing safetysub-deep-subscription- Subscribe deep in component tree where data is neededsub-avoid-watch-in-render- Avoid calling watch() in render for one-time readssub-usewatch-default-value- Provide defaultValue to useWatch for initial rendersub-useformcontext-sparingly- Use useFormContext sparingly for deep nesting
3. Controlled Components (HIGH)
ctrl-usecontroller-isolation- Use useController for re-render isolationctrl-avoid-double-registration- Avoid double registration with useControllerctrl-controller-field-props- Wire Controller field props correctly for UI librariesctrl-single-usecontroller-per-component- Use single useController per componentctrl-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 cachingvalid-dynamic-schema-factory- Use schema factory for dynamic validationvalid-error-message-strategy- Access errors via optional chaining or lodash getvalid-inline-vs-resolver- Prefer resolver over inline validation for complex rulesvalid-delay-error- Use delayError to debounce rapid error displayvalid-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 mapsarray-complete-default-objects- Provide complete default objects for field array operationsarray-separate-crud-operations- Separate sequential field array operationsarray-unique-fieldarray-per-name- Use single useFieldArray instance per field namearray-virtualization-formprovider- Use FormProvider for virtualized field arrays
6. State Management (MEDIUM)
formstate-destructure-formstate- Destructure formState properties before renderformstate-useformstate-isolation- Use useFormState for isolated state subscriptionsformstate-getfieldstate-for-single-field- Use getFieldState for single field state accessformstate-subscribe-to-specific-fields- Subscribe to specific field names in useFormStateformstate-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 sourceinteg-shadcn-select-wiring- Wire shadcn Select with onValueChange instead of spreadinteg-mui-controller-pattern- Use Controller for Material-UI componentsinteg-value-transform- Transform values at Controller level for type coercion
8. Advanced Patterns (LOW)
adv-formprovider-memo- Wrap FormProvider children with React.memoadv-devtools-performance- Disable DevTools in production and during performance testingadv-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
- 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
What ships with it: 44 files
81.9 KB alongside SKILL.md
references/
- adv-devtools-performance.md1.8 KB
- adv-formprovider-memo.md2.0 KB
- adv-testing-wrapper.md1.8 KB
- array-complete-default-objects.md1.9 KB
- array-separate-crud-operations.md2.0 KB
- array-unique-fieldarray-per-name.md1.7 KB
- array-use-field-id-as-key.md1.7 KB
- array-virtualization-formprovider.md1.8 KB
- ctrl-avoid-double-registration.md1.3 KB
- ctrl-controller-field-props.md1.7 KB
- ctrl-local-state-combination.md2.0 KB
- ctrl-single-usecontroller-per-component.md1.8 KB
- ctrl-usecontroller-isolation.md1.9 KB
- formcfg-async-default-values.md1.8 KB
- formcfg-default-values.md1.7 KB
- formcfg-revalidate-mode.md1.5 KB
- formcfg-should-unregister.md1.8 KB
- formcfg-useeffect-dependency.md1.5 KB
- formcfg-validation-mode.md1.6 KB
- formstate-avoid-isvalid-with-onsubmit.md1.7 KB
- formstate-destructure-formstate.md1.3 KB
- formstate-getfieldstate-for-single-field.md1.6 KB
- formstate-subscribe-to-specific-fields.md1.5 KB
- formstate-useformstate-isolation.md1.8 KB
- integ-mui-controller-pattern.md1.6 KB
- integ-shadcn-form-import.md1.6 KB
- integ-shadcn-select-wiring.md1.9 KB
- integ-value-transform.md1.5 KB
- _sections.md1.8 KB
- sub-avoid-watch-in-render.md1.6 KB
- sub-deep-subscription.md2.0 KB
- sub-useformcontext-sparingly.md1.6 KB
- sub-usewatch-default-value.md1.3 KB
- sub-usewatch-over-watch.md1.9 KB
- sub-usewatch-with-getvalues.md1.5 KB
- sub-watch-specific-fields.md1.8 KB
- valid-delay-error.md1.4 KB
- valid-dynamic-schema-factory.md1.7 KB
- AGENTS.md9.6 KB
- metadata.json1.1 KB
4 more files not listed here. See all 44 in the repository.