useForm
Lightweight form state management with validation, touched tracking, and submit handling. No external dependencies.
Installation
Usage
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| values | T | — | Current form values object. |
| errors | Partial<Record<keyof T, string>> | — | Validation error messages. |
| touched | Partial<Record<keyof T, boolean>> | — | Which fields have been blurred. |
| isSubmitting | boolean | — | True while onSubmit is running. |
| isDirty | boolean | — | True when values differ from initialValues. |
| isValid | boolean | — | True when validate returns no errors. |
| setValue | (field, value) => void | — | Set a single field value. |
| handleChange | (field) => ChangeHandler | — | Returns an onChange handler. |
| handleBlur | (field) => () => void | — | Returns an onBlur handler. |
| handleSubmit | (e?) => void | — | Runs validation then calls onSubmit. |
| reset | () => void | — | Resets to initialValues. |