Skip to content

Provide context (query key) to onError callback #3108

Answered by TkDodo
jcready asked this question in Ideas
Discussion options

You must be logged in to vote

for this use case (global error handling) you can (and likely should) use the global callbacks on the queryCache instead of defaultOptions.

I've gone into details here: https://tkdodo.eu/blog/react-query-error-handling

not only will the global callbacks only be called once per cache entry (rather than once per observer), they also get the whole query / mutation passed as second parameter.

see also:

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jcready
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants