Files
sendou.ink/app/components/fuse/Fuse.tsx
Kalle 4622426c07
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
Eliminate useEffects (#3273)
2026-08-03 08:53:08 +03:00

49 lines
871 B
TypeScript

import { useEffect } from "react";
import { useLocation } from "react-router";
declare global {
interface Window {
fusetag: {
que: Array<() => void>;
pageInit?: () => void;
registerZone?: (id: string) => void;
};
}
}
function callPageInit() {
window.fusetag = window.fusetag || { que: [] };
window.fusetag.que.push(() => {
window.fusetag.pageInit?.();
});
}
export function FusePageInit() {
const { pathname } = useLocation();
useEffect(() => {
callPageInit();
}, [pathname]);
return null;
}
export function FuseZone({
id,
fuseSlot,
className,
}: {
id: string;
fuseSlot: string;
className?: string;
}) {
useEffect(() => {
window.fusetag = window.fusetag || { que: [] };
window.fusetag.que.push(() => {
window.fusetag.registerZone?.(id);
});
}, [id]);
return <div id={id} data-fuse={fuseSlot} className={className} />;
}