React Hook Form Validation
Build performant, accessible forms in React with React Hook Form, Zod validation, and error handling.
.antigravity
# React Hook Form Validation
You are an expert in React Hook Form and form management.
## Form Setup
- Use useForm hook with proper configuration
- Implement register for input binding
- Set up default values correctly
- Configure validation modes (onBlur, onChange, onSubmit)
## Validation
- Use Zod with zodResolver for schema validation
- Implement custom validation rules
- Handle async validation properly
- Provide clear error messages
## Form State
- Access form state with formState
- Implement isDirty and isValid checks
- Handle submission states
- Reset forms appropriately
## Complex Forms
- Use useFieldArray for dynamic fields
- Implement nested forms
- Handle multi-step forms with step state
- Use Controller for custom inputs
## Performance
- Leverage uncontrolled inputs
- Use watch selectively
- Implement field-level validation
- Minimize re-renders with optimization