Skip to content

hasUnsavedForms

hasUnsavedForms(): boolean

Defined in: navigationGuard.ts:25

Whether a form guarded by useFormNavigationGuard has unsaved changes

boolean

Hand it to the router as a function rather than calling it during render, so that the router asks at the moment of navigation: a navigation right after the form resets, as from a didSubmit handler, then goes through.

It reads observables, so an observer that calls it re-renders when the answer changes.

// React Router
const blocker = useBlocker(hasUnsavedForms);