PHP 8.2.31
Preview: useWarnOnLeave.js Size: 533 B
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/AutoLaunch/hooks/useWarnOnLeave.js

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

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

Directory Contents

Dirs: 0 × Files: 4

Name Size Perms Modified Actions
17.31 KB lrw-r--r-- 2026-04-27 23:36:32
Edit Download
948 B lrw-r--r-- 2026-04-27 23:36:32
Edit Download
711 B lrw-r--r-- 2026-02-27 04:48:52
Edit Download
533 B lrw-r--r-- 2026-02-27 04:48:52
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).