Confirm Dirty
The confirmDirtyPlugin — warn before leaving with unsaved changes
Confirm Dirty
confirmDirtyPlugin warns before the user leaves the page while the form has unsaved changes.
Usage
import { confirmDirtyPlugin } from "formify-js";
plugins: [
confirmDirtyPlugin({
message: "You have unsaved changes — leave anyway?",
}),
]Options
| Option | Type | Default | Description |
|---|---|---|---|
message | string | browser default | Text shown in the beforeunload prompt. |
Things to know
- Registers a
beforeunloadlistener on mount and removes it on unmount. - Only warns while the form is
dirty(values differ frominitialValues).