Skip to content
Discussion options

You must be logged in to vote

I'd love to know, is throwing an error via a request not enough to trigger that react query error status.

It should be enough. Throwing in an async function will convert the Error to a failed promise. react-query will then give you the result in an error state (isError: true and state === 'error'). You can see that in action here: https://codesandbox.io/s/nostalgic-feynman-wrm60

Please note that react-query retries queries per default (3 times, with an exponential backoff). So you will not "immediately" see the error (it takes a couple of seconds in the example). You can customize this in the query options: https://react-query.tanstack.com/docs/guides/query-retries

If this is not workin…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by idenyigabriel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants