Files
gruperly/.agents/skills/react-hook-form/AGENTS.md
2026-09-04 16:49:24 -03:00

10 KiB

React Hook Form

Version 2.1.0
Community
July 2026

Note: This document targets React Hook Form codebases. It is mainly for agents and LLMs to follow when maintaining, generating, or refactoring forms. Humans may also find it useful, but guidance here is optimized for automation and consistency by AI-assisted workflows.


Abstract

Focused guide to the React Hook Form decisions a capable model gets wrong. Contains 35 rules across 7 categories, verified against react-hook-form 7.82.0 by diffing the shipped type definitions and type-checking every code block under tsc --strict against the real package types. Covers where a subscription must live to isolate re-renders, the third useForm generic that transforming resolvers require, the options that silently drop data from the submitted payload (register disabled, shouldUnregister, useFieldArray disabled), the NaN that valueAsNumber produces for an empty input, server error handling via setError('root.*'), resetDefaultValues() for rebasing the dirty baseline after a save, and the Watch / FormStateSubscribe / FieldArray render-prop components. Rules that merely restate what the library already does correctly have been removed.


Table of Contents

  1. Form Configuration — CRITICAL
  2. Field Subscription — CRITICAL
  3. Controlled Components — HIGH
  4. Validation Patterns — HIGH
  5. State Management — MEDIUM-HIGH
  6. Field Arrays — MEDIUM-HIGH
  7. Integration Patterns — MEDIUM

References

  1. https://react-hook-form.com/docs
  2. https://react-hook-form.com/advanced-usage
  3. https://react-hook-form.com/docs/useform
  4. https://react-hook-form.com/docs/useform/subscribe
  5. https://react-hook-form.com/docs/useform/seterror
  6. https://react-hook-form.com/docs/useform/setvalue
  7. https://react-hook-form.com/docs/useform/resetdefaultvalues
  8. https://react-hook-form.com/docs/useform/formstate
  9. https://react-hook-form.com/docs/usewatch
  10. https://react-hook-form.com/docs/usecontroller
  11. https://react-hook-form.com/docs/usefieldarray
  12. https://react-hook-form.com/docs/useformstate
  13. https://github.com/react-hook-form/react-hook-form/releases
  14. https://github.com/react-hook-form/resolvers
  15. https://ui.shadcn.com/docs/components/form

Source Files

This document was compiled from individual reference files. For detailed editing or extension:

File Description
references/_sections.md Category definitions and impact ordering
assets/templates/_template.md Template for creating new rules
SKILL.md Quick reference entry point
metadata.json Version and reference URLs