useBeforeUnload
Setup a callback to be fired on the window's beforeunload
event. This is
useful for saving some data to window.localStorage
just before the page
refreshes.
Note: The callback
argument should be a function created with
React.useCallback()
.
function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any): void;