Form State: isDirty, isValid, isSubmitting
You'll learn how to use React Hook Form's formState flags to create smarter, more responsive forms.
React Hook Form automatically tracks three essential flags that tell you what's happening with your form right now:
The Three Essential Flags
isDirty: Has the user changed anything from the default values? Think of it like a "modified" indicator in a text editor—the moment someone types or selects something different, this becomes true.
isValid: Do all fields currently pass their validation rules? This respects both your built-in validation (like required) and any schema validation (like Zod). It's your green light for submission.
isSubmitting: Is the form currently being submitted? Becomes true when handleSubmit fires and stays true until your async submission completes (or errors). Perfect for showing loading states.
Common Patterns
Disable the submit button until the form is both valid and dirty:
const { formState: { isDirty, isValid, isSubmitting } } = useForm();
<button
disabled={!isDirty || !isValid || isSubmitting}
>
{isSubmitting ? 'Saving...' : 'Save Changes'}
</button>
Show a "You have unsaved changes" warning:
{isDirty && <p>You have unsaved changes</p>}
The beauty here is you don't maintain this state yourself—React Hook Form computes it automatically by comparing current values against defaults and running validations.
Key Takeaway: Use isDirty, isValid, and isSubmitting from formState to conditionally enable buttons, display loading indicators, and warn about unsaved changes—all without manually tracking these states yourself.