Employee profile form

A production-leaning `react-hook-form` example paired with a quick state-management reference.

useForm

Creates the form API, default values, validation mode, and state object that everything else reads from.

register

Connects native inputs to the form and attaches rules without extra wrappers.

controller

Bridges controlled components into the same form state when direct registration is not possible.

reset

Restores defaults, clears errors, and can optionally keep parts of the current state.

State interactions

Initial render

Required: Rules are registered, but untouched fields usually do not show errors yet.

Dirty: `isDirty` is false because current values still match defaults.

Validity: `isValid` depends on the chosen validation mode.

Reset: `reset()` returns to this clean baseline.

User enters a valid value

Required: The required rule is now satisfied.

Dirty: Dirty state becomes true because the value diverged from the default.

Validity: Validity turns true once validation runs and no other errors remain.

Reset: `reset()` restores the original value and clears dirty state.

User clears a required field

Required: The field fails the required rule again.

Dirty: The field stays dirty until it matches the default exactly.

Validity: `isValid` becomes false after validation runs.

Reset: `reset()` clears the error when defaults are valid.

reset(newValues)

Required: Rules stay attached to the field definitions.

Dirty: Dirty tracking is re-based against the new defaults.

Validity: Validity is recalculated from the new reset state.

Reset: Those new values become the fresh clean snapshot.

Employee profile form

This page demonstrates react-hook-form with ten fields and built-in validation.