🐐 GOAT Shell

Current path: home/fresvfqn/emergencywaterdamagenyc.com/wp-content/plugins/extendify/src/Launch/hooks/



⬆️ Go up: Launch

📄 Viewing: useWarnOnLeave.js

import { useEffect } from '@wordpress/element';

export const useWarnOnLeave = (enabled = true) => {
	// Display warning alert if user tries to exit
	useEffect(() => {
		if (!enabled) return;
		const handleUnload = (event) => {
			event.preventDefault();
			return (event.returnValue = '');
		};
		const opts = { capture: true };
		window.addEventListener('beforeunload', handleUnload, opts);
		return () => {
			window.removeEventListener('beforeunload', handleUnload, opts);
		};
	}, [enabled]);
};


📤 Upload File


📁 Create Folder