Skip to content

global and local onError callbacks related questions #3125

Answered by TkDodo
cloudcompute asked this question in Q&A
Discussion options

You must be logged in to vote

a. Is it possible to execute the onError both at a global and local level for a given query or mutation. For example, use global onError to display toast and local onError to handle local logic, for example navigate to this particular route if error occurs.

if by global you man the onError callback on the queryCache then yes, because the queryCache callbacks always get executed. However, the onError specified under defaultOptions of the queryClient will be overwritten by specific handlers on useQuery because the defaultOptions are "fallbacks" / "defaults".

b. Is it possible to execute global onError conditionally, like I do not want to show a toast for some errors. I think it might be …

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@saeedPadyab
Comment options

@TkDodo
Comment options

@saeedPadyab
Comment options

@philippks
Comment options

@TkDodo
Comment options

Answer selected by cloudcompute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants