T
TanStack4y ago
funny-blue

Stop refresh interval after so many retries or on certain error

I want to stop refreshing I get 500 errors, or at least have a way to distinguish between retries/refreshes in the onError callback.
5 Replies
rising-crimson
rising-crimson4y ago
refetchInterval can take a function for exactly this purpose.
funny-blue
funny-blueOP4y ago
but the function only gets the old data as an argument. Not the error/retries
rising-crimson
rising-crimson4y ago
it gets passed the whole query as a second parameter, which contains the error as well.
funny-blue
funny-blueOP4y ago
ooooh! I thought that would just be the query key and other options. thanks!!
rising-crimson
rising-crimson4y ago
query.state.error is what you're looking for.

Did you find this page helpful?