Untitled
unknown
plain_text
2 years ago
481 B
8
Indexable
useEffect(() => {
const handleBeforeUnload = (e) => {
console.log('Attempting to navigate away during upload'); // Debugging line
if (isUploading) {
const message = 'An upload is in progress. Are you sure you want to leave?';
e.returnValue = message;
return message;
}
};
window.addEventListener('beforeunload', handleBeforeUnload);
return () => window.removeEventListener('beforeunload', handleBeforeUnload);
}, [isUploading]);Editor is loading...
Leave a Comment