import { useEffect } from 'react';

const useBeforeUnloadNavigationBlock = (shouldWarn)=>{
    useEffect(()=>{
        if (shouldWarn) {
            const handleBeforeUnload = (e)=>{
                e.preventDefault();
                e.returnValue = true;
            };
            window.addEventListener('beforeunload', handleBeforeUnload);
            return ()=>{
                window.removeEventListener('beforeunload', handleBeforeUnload);
            };
        }
    }, [
        shouldWarn
    ]);
};

export { useBeforeUnloadNavigationBlock };
//# sourceMappingURL=useNavigateAwayWarning.mjs.map
