How to use useQueries
Is this the correct way to combine two get requests with useQueries?
8 Replies
unwilling-turquoise•2y ago
yes
exotic-emeraldOP•2y ago
@TkDodo 🔮 This is my result, is it enough to use error instead of isError? Since if isError is true there will be an error object? And should i use isLoading instead of while isPending? Will the two request share the same isLoading? For example i just need one if(isLoading) return <LoadingSpinner/>?
@TkDodo 🔮 i get the data like this
But since it's contain the both data results how can i get the right one? If i use index i guess that will break if there sometimes will not return data from both requests?
Is there maybe a way to find the data based on the queryKey, i don't think this is the best way?
unwilling-turquoise•2y ago
order in results is guaranteed to be the same as input order
exotic-emeraldOP•2y ago
So using index like this is good to go?
unwilling-turquoise•2y ago
Yeah, or destruct
exotic-emeraldOP•2y ago
How would i deatruct it in this case?
unwilling-turquoise•2y ago
Destruct the array that comes into combine
exotic-emeraldOP•2y ago
Thank you for always giving help🙏🏻
This seems to work