T
TanStack2y ago
rival-black

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
eager-peach
eager-peach2y ago
with queryClient.refetchQueries
rival-black
rival-blackOP2y ago
Thank you!

Did you find this page helpful?