mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 16:22:44 +00:00
Handle unsaved warning with onbeforeunload
This commit is contained in:
@@ -78,13 +78,15 @@ const HomePage =(props)=>{
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
||||
const previousBeforeUnload = window.onbeforeunload;
|
||||
|
||||
window.onbeforeunload = handleBeforeUnload;
|
||||
|
||||
document.addEventListener('keydown', handleControlKeys);
|
||||
|
||||
return ()=>{
|
||||
document.removeEventListener('keydown', handleControlKeys);
|
||||
window.removeEventListener('beforeunload', handleBeforeUnload);
|
||||
window.onbeforeunload = previousBeforeUnload;
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user