Using errorElement with react-query #249
robcaldecott
started this conversation in
General
Replies: 2 comments 1 reply
-
I have a super bare bones application which basically just does this: let routes = [{
path: '/',
element: 'app',
errorElement: 'error',
loader: async () => {
throw new Error('Something went wrong!')
}
}] and it shows |
Beta Was this translation helpful? Give feedback.
1 reply
-
Looks like a bug
Tanner Linsley
…On Mar 25, 2022, 12:48 PM -0600, Rob Caldecott ***@***.***>, wrote:
Is that a bug @tannerlinsley ?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying this library with
react-query
to see if it is possible to move the loading and error states of a query component into the router in order to simplify the code (by easily sharing pending/error components across the app.)While the
pendingElement
works a treat I just cannot geterrorElement
to work. In my example I am callingfetchQuery
in the routeloader
which is callingfetch
and throwing an exception, but theerrorElement
is never triggered.Either this is a bug or I am missing something here.
https://codesandbox.io/s/kind-smoke-hubvm7?file=/src/App.tsx:2066-2076
In this example just click on a post. This will throw an exception but it does not cause the error to render and instead just attempts to render the actual
element
instead.I guess I'm looking for the best practices here when using
react-query
. Should we stick to handling errors in our query components? Should we handing the pending state in both the router and our components to cover all bases?Any here is some code:
Beta Was this translation helpful? Give feedback.
All reactions