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.

Viewing query keys

Viewing query keys

- [Instructor] Let's talk a little bit about queryKeys, and how TanStack Query is caching and managing our data. So we think about a queryKey as an array. If we take a look here on line 32, our queryKey is caching everything on the user. And then we're also passing in a dynamic value here, in this case, username, which is going to make sure that fetchGitHubUser has access to the correct username. Now, it can feel kind of unclear what exactly is being cached when we are saying there's this cache that's been created. You could trust that and it would probably serve you pretty well, but if you did want to dig into a little bit more about what data is being cached, you can use a cache log here. And we're going to start by creating a function that's going to take a look at this. So first things first, let's create that function. We're going to then set this to a function here that's going to manage cachedData. And this cachedData is going to be set equal to queryClient. So, check in with…

Contents