Should select on Suspense Query throw errors? #9957
Replies: 2 comments
-
|
@TkDodo I found this discussion and PR you made. Is it related to this issue? The docs addition doesn’t mention |
Beta Was this translation helpful? Give feedback.
-
|
if you have a query/packages/query-core/src/queryObserver.ts Lines 547 to 552 in f15b7fc then, the react integration will throw that error to the error boundary: query/packages/react-query/src/useBaseQuery.ts Lines 124 to 142 in f15b7fc you can clearly see that if you take your own example and put it in a sandobx: https://stackblitz.com/edit/tanstack-query-zmlk4cr7?file=src%2Findex.tsx&preset=node |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Dear TanStack team,
I have a question connected to React Suspense Query
selectfunction and how throwingerrorinside of it is handled.Lets look at the following example:
I would expect the
datato always be astring, this is why I used suspense.But in this case, even tho Typescript tells me
datais astring, I will end up with a query in error state and data that will beundefined.Also, rendering of the component will not be canceled by the throw error in the
selectItemByIdbecause it is caught by Query Observer and never thrown https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L541.Is my assumption right, that component
useSuspenseQueryshould throw if error occurs in theselect?Beta Was this translation helpful? Give feedback.
All reactions