Replies: 2 comments 1 reply
-
I have never used suspense for data fetching. You can According to https://reactjs.org/docs/concurrent-mode-suspense.html#handling-errors, ErrorBoundaries are the way to handle errors with suspense ... |
Beta Was this translation helpful? Give feedback.
0 replies
-
We also have use cases to use suspense for loading (to show global loading), but would like to handle errors within a component. So, it'd definitely be nice to decouple this |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Just now I was trying to create a query that will trigger Suspense for a loading screen, but with custom error handling rather than using an error boundary.
However I noticed that just passing
useErrorBoundary: false
to this one specific query, to override the global setting, was not working as expected.Checking the source I found that currently the
useErrorBoundary
option is tied to thesuspense
option, by checking if either is set totrue
.Reproduction: https://codesandbox.io/s/react-query-suspense-without-error-boundary-cn6y6?file=/src/App.js
The problem is fixed by removing
suspense: true
from thequeryClient
options, since then the error boundary won't actually be used. However the Suspense fallback loading screen is then not shown.Does it make sense to decouple these and allow for using Suspense for the loading state while opting out of using an error boundary?
Beta Was this translation helpful? Give feedback.
All reactions