Description
Tanstack Query is a powerful library for managing data fetching, caching, and global state in an application, so we are using this library to manage our state. Currently, each of our queries simply fetches it state and returns it. However, this can lead to us unintentionally refetching the same data multiple times.
For instance, if we first fetched all albums and stored it under query key ['albums'] and then later on fetched a single album with id 1 under query key ['albums', 1], it would make another request despite the fact that album 1 is likely already in the cache.
Task
Go through all of our Tanstack Query hooks and if they are list queries, update them to manually populate the cache with individual items when they fetch data successfully.
Description
Tanstack Query is a powerful library for managing data fetching, caching, and global state in an application, so we are using this library to manage our state. Currently, each of our queries simply fetches it state and returns it. However, this can lead to us unintentionally refetching the same data multiple times.
For instance, if we first fetched all albums and stored it under query key
['albums']and then later on fetched a single album with id1under query key['albums', 1], it would make another request despite the fact that album 1 is likely already in the cache.Task
Go through all of our Tanstack Query hooks and if they are list queries, update them to manually populate the cache with individual items when they fetch data successfully.