# useFormState (@salmonui/inputs/form/state)

> The useFormState function of @salmonui/inputs/form/state: Dirty tracking against the initial values of a native form:

Canonical: https://salmonui.dev/docs/reference/inputs/form-state/useFormState

```ts
import { useFormState } from '@salmonui/inputs/form/state';
```

Entry index: https://salmonui.dev/docs/reference/inputs/form-state (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/inputs/form-state.md).

## Reference

Kind: function

```ts
function useFormState(): FormState;
```

Dirty tracking against the initial values of a native form:

  const form = useFormState();
  <Form ref={form.ref}>...</Form>
  {form.isDirty ? <Button onClick={form.reset}>Discard</Button> : null}

Initial values are the form's FormData when it mounts; a form that
mounts again (a drawer that opens again, a `key` change after a save)
takes a new snapshot and starts clean. Controlled fields whose value the
parent holds count as dirty until the parent resets them.
