import { useEffect, useState } from "preact/hooks"; interface LoadingGlobalHook { show: () => void; hide: () => void; } declare global { var $loading: LoadingGlobalHook | undefined; } export default function Loading() { const [visible, setVisible] = useState(false); useEffect(() => { globalThis.$loading = { show: () => setVisible(true), hide: () => setVisible(false), }; return () => { delete globalThis.$loading; }; }, []); return (
); }