Replies: 2 comments
-
Please, if you want to use suspense, you need to understand how suspense works :) This is independent of react-query. With suspense, data is guaranteed to be defined after the suspense call because react suspends if it has no data. We even mention that in the docs:
The example from the dependent query docs site literally just becomes:
This is actually what worries me with suspense on the client - two call in the same component to I also have a blog post on this topic: https://tkdodo.eu/blog/seeding-the-query-cache |
Beta Was this translation helpful? Give feedback.
-
For anyone concerned: For cases where you want to run the Q2 only if you get a specific result from Q1, you could use composition and move Q2 down the component tree and use an early return.
-->
|
Beta Was this translation helpful? Give feedback.
-
We are looking at using useSuspenseQuery in our react project, but have a few questions on how to proceed. As a background info we are also moving from old redux based approach to tanstack/query in general
Normally when you chain useQuery, you use the
enabled
property of useQueryOptions to disable successive requests, until the first is finished (ref docs - dependent Query)How would we proceed to do this with useSuspenseQuery? There is no
enabled
prop there, so we cannot pause the query, until the predecessor is done fetching.I know that the docs talks about performance hits, when doing multiple backend requests to build data for the UI layer. But our data comes from many different sources (each with their own distinct database) so it's not possible to query across those in the backend
Beta Was this translation helpful? Give feedback.
All reactions