import { useEffect } from 'react';

const useBeforeUnload = (beforeunload) => {
    useEffect(() => {
        const handleBeforeUnload = (event) => {
            if (beforeunload) {
                event.preventDefault();
            }
        };
        window.addEventListener('beforeunload', handleBeforeUnload);
        return () => {
            window.removeEventListener('beforeunload', handleBeforeUnload);
        };
    }, [beforeunload]);
};

export { useBeforeUnload };
//# sourceMappingURL=UseBeforeUnload.js.map
