A React Hook to perform actions before the page is unloaded (e.g., closing, refreshing the page) and optionally trigger a browser-native confirmation dialog. set preventDefault to true to show the confirm leave dialog.
A function that will be called right before the page is potentially unloaded.
/** * A callback function to run before the page is unloaded * * @param{BeforeUnloadEvent}event - `BeforeUnloadEvent`, the event object * @returns{void} `void` */exporttypeUseBeforeUnloadCallback= (event: BeforeUnloadEvent) =>void
exportinterfaceUseBeforeUnloadOptions {/** * Whether to prevent the default behavior of the event, which leads to showing a browser-native message * * @seehttps://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event * * @defaultValue false */preventDefault?: boolean}