Replies: 2 comments 2 replies
-
My response to this use case is that if you expect sibling suspenders to fire and suspend simultaneously, you should put their queries in their own respective components and let SuspenseList do the work of parallelizing them. I understand what you're proposing, but this would add significant overhead to the API for an edge case that is not intended to be solved with React Query itself. |
Beta Was this translation helpful? Give feedback.
-
Futhermore, if you have a view that uses multiple queries, but both must complete before it can be rendered, then you should use the |
Beta Was this translation helpful? Give feedback.
-
I found some inefficient case
react-query
in Suspense mode. So I suggest a little changes.case 1: queries are suspended by previous query!
brandsQuery
is not executed tillproductQuery
is prepared. Because eachuseQuery
throws suspender and it blocks function execution even if the queries are not dependent for each query.So you can think about merging the fetch operation. But it cause problem.
case 2: unable to
renders as you fetch
Because the two operation are wrapped in a query, we can't divide rendering concerns. In above example,
<ProductTitle />
keeps suspending even iffetchProductById
result resolved.solution (for me)
So I'm using wrapped
useQuery
in production, like:it is similar to official react document
example: https://codesandbox.io/s/intelligent-thunder-ir39b?file=/src/App.js
now the exact suspense guideline is unclear... but I think above problems can be common and official guideline interface is good at this moment. How about considering to add interface
react-query
? Let me know if there's what I misunderstand howreact-query
works.If this idea accepted, I guess I can contribute this. Or welcome to discuss other edge cases.
Beta Was this translation helpful? Give feedback.
All reactions