Skip to content
Discussion options

You must be logged in to vote

you can use the onError property globally in the defaultOptions of the queryClient, but if you override this on a query, it will not be called. For an error handler that is always called, not matter what, you have to put it on the queryCache:

new QueryClient({
    queryCache: new QueryCache({ onError: (error) => ... }),
})

this is documented here: https://react-query.tanstack.com/reference/QueryCache

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@cubecleveland
Comment options

Answer selected by TkDodo
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@cubecleveland
Comment options

@TkDodo
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants