usePageLeave

A hook to detect page leave

usePageLeave(() => { console.log('User is about to leave the page'); });