T
TanStack3y ago
wise-white

implement polling in react with useQuery

I want to implement a polling query in react, but i want the query to stop re-fetching as soon as the expected data hits the app It's more like re-fetching until the data has been defined (for context, I'm using it to verify solana pay transactions https://solanapay.com/ What's the best way to do this?
3 Replies
wise-white
wise-whiteOP3y ago
I can just add a refetchInterval to implement re-fetching after intervals But how to stop the fetch after data is in a certain format (perhaps after parsing with zod)
complex-teal
complex-teal3y ago
refetchInterval can be a function which gets the latest data passed. return false to stop polling
wise-white
wise-whiteOP3y ago
thanks for the help, works! btw I loved your blog series on react query, it was pretty good :Salute:

Did you find this page helpful?