import { useEffect } from 'react'; export function usePoll(fn: () => void | Promise, ms: number) { useEffect(() => { let active = true; const tick = async () => { if (!active) return; await fn(); setTimeout(tick, ms); }; tick(); return () => { active = false; }; }, [fn, ms]); }