From the course: TanStack Query: Efficient Data Fetching and State Management
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Creating parallel queries - TanStack Query Tutorial
From the course: TanStack Query: Efficient Data Fetching and State Management
Creating parallel queries
- [Instructor] Once we have sent our first query, the question then becomes how do we send more? How do we get more data? And so the way that we do that is we will add another query call to our component. So here we have the useQuery hook that's being called and we actually want to use two of these. So changes will need to be made, but we're going to have two. Let's see if we can get 'em on the same page. So the first one we'll call userQuery1. The second we'll call, you guessed it, userQuery2. Then we want to pass a different query key to this as well. So we're going to say eveporcello. For the second, we'll use another GitHub name, moontahoe, and then we're going to use the same fetch call here, but this time we're going to request that moontahoe user. So now that we've done that, we need to make a few changes down here. So what we need to do is return a loading state. So we'll say if userQuer1.isLoading or userQuery2.isLoading. Now another thing to say is that isLoading, you may…