T
TanStack2y ago
equal-aqua

Refetch data on error

Hey, on Error I want to render a toast with a button that will refetch my query. In v4 I could add onError callback to useQuery , call my toast method there and pass it a refetch method to a button onClick callback. In v5 there is a global onError callback for QueryCache instance, but I don't know how can I refetch my query there as I have no access to refetch method.
2 Replies
like-gold
like-gold2y ago
with queryClient.refetchQueries
equal-aqua
equal-aquaOP2y ago
Thank you!

Did you find this page helpful?