Untitled
unknown
plain_text
2 years ago
477 B
7
Indexable
useEffect(() => {
const handleBeforeUnload = (e) => {
if (isUploading) {
const message = 'An upload is in progress. Are you sure you want to leave?';
e.returnValue = message; // For most browsers
return message; // For some older browsers
}
};
if (isUploading) {
window.addEventListener('beforeunload', handleBeforeUnload);
}
return () => window.removeEventListener('beforeunload', handleBeforeUnload);
}, [isUploading]);Editor is loading...
Leave a Comment