#Refresh Infinite Query on Interval

4 messages · Page 1 of 1 (latest)

quasi flint
#

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)?

limber ravine
#

I do not understand the use case. What’s wrong with refetchInterval?

quasi flint
#

I don't want to refresh the current data, I want to fetch the previous page on an interval. Can that be done with refresh interval?

limber ravine
#

No. I think useEffect is fine for you 🙂