/* eslint-disable no-unused-expressions */ import { useEffect } from 'react'; export function useIntervalRefetch( refetchFunctions: Array<() => void>, intervalTime?: number, /** refetchFunctions 改变之后立马刷新 */ realTime?: boolean, ) { useEffect(() => { if (realTime) { for (const func of refetchFunctions) { func && func(); } } const timer = window.setInterval(() => { for (const func of refetchFunctions) { func && func(); } }, intervalTime ?? 120000); return () => { window.clearInterval(timer); }; }, [refetchFunctions, intervalTime, realTime]); }