View as Markdown

API reference: @salmonui/inputs/form/state

useFormStatefunction

import { useFormState } from '@salmonui/inputs/form/state';
function useFormState(): FormState;

Dirty tracking against the initial values of a native form:

const form = useFormState();

...
{form.isDirty ? : 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.