UNPKG

@hypothesis/frontend-shared

Version:

Shared components, styles and utilities for Hypothesis projects

11 lines (10 loc) 556 B
/** * Registers an event listener to window's 'beforeunload' if `hasUnsavedData` is true. * It also unregisters the event if `hasUnsavedData` is false or the component is unmounted. * * This event listener makes the browser warn the user about potential unsaved changes, * and gives the user the opportunity to cancel the page unload if desired. * * @link https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event */ export declare function useWarnOnPageUnload(hasUnsavedData: boolean, window_?: Window & typeof globalThis): void;