TanStackT
TanStack3y ago
5 replies
wet-aqua

Cache query errors

Hello.

I wonder if there is an option that I could cache useQuery errors to account for staleTime?

I have extracted useQuery into separate hook and I am using it in several places. I am also displaying error when request fails in onError callback of that useQuery. Now when re-used in several places it is causing the error to display several times.
I would have hoped the 'onError' would be called just once and there would be no re-fetches on windowFocus for given staleTime.

Please advise.
Was this page helpful?