Ask for confirmation before leaving the app, like closing the tab or clicking external links. Can only work after the user interacted with the page in any way.
const MyComponent = () => { const { formState } = useForm(); usePreventLeave(formState.isDirty); return <form />} Copy
const MyComponent = () => { const { formState } = useForm(); usePreventLeave(formState.isDirty); return <form />}
flag to indicate if the page should be blocked right now
Generated using TypeDoc
Ask for confirmation before leaving the app, like closing the tab or clicking external links. Can only work after the user interacted with the page in any way.
Example