Replies: 2 comments 4 replies
-
Yes, I would want that. No, I don't really know how to do it 😅 . API wise, I think the promise should just unwrap data:
This would work great for initial fetches, and can also be used inside conditions like if statements. I'm just wondering how this would work:
If you have an idea how to approach this, feel free to try a PR ❤️ |
Beta Was this translation helpful? Give feedback.
-
Isn't this what Doesn't solve the duplicate (a useQuery() at the top of the tree and useSuspenseQuery()s further down the tree, using the same arguments) part though |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It's be nice to have something to support the
React.use()
-hook nicely.There might be a previous discussion about this (couldn't find one) or a good reason why this doesn't exist.
Why?
It'd make it easier to parallelize queries as far up the tree as possible when doing SPAs.
How
Implementation details
Promise
needs to be stable so it doesn't change with every render, otherwiseuse()
will cause infinite re-renders.useInfiniteQuery()
tooAlternative API
Example usage
Workaround today
The way I work around this today is that I have a
useQuery()
at the top of the tree anduseSuspenseQuery()
s further down the tree, using the same arguments. This is a bit of a hack, but it works.Beta Was this translation helpful? Give feedback.
All reactions