TanStackT
TanStack3y ago
4 replies
moderate-tomato

Refresh Infinite Query on Interval

We are using useInfiniteQuery but want to fetch the previous page every 5 seconds. So we've created a custom hook that calls useInfiniteQuery and then has a useEffect that sets up an interval. However, when there are multiple components calling the hook, we only want one interval between them. Is there a way to check how many subscribers a hook has (which we can use to set up an interval on the first subscriber)?
Was this page helpful?