Untitled

 avatar
unknown
plain_text
a year ago
481 B
5
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