What is the best way to fetch data which is dependent on results from an infiniteQuery?
Let's say I have a personal database of movies which I've seen which populates on the page via an infinite scroll mechanism like the simple example here: https://tanstack.com/query/v4/docs/react/guides/infinite-queries. Whenever the page loads a new batch of movies via the infiniteQuery I want to query IMDB for information on those new movies while still maintaining my old IMDB queries so they can refetch as needed. Is there a good way to do this?
2 Replies
foreign-sapphire•3y ago
What if your infinite query would fetch from two APIs at the same time (your API + IMDB)?
foreign-sapphire•3y ago
Another solution could be to query the data in the individual items down the tree instead of the parent container. In order to prevent numerous queries in quick succession, you might use batsh*t (https://tanstack.com/query/v5/docs/react/community/community-projects).
Overview | TanStack Query Docs
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your web applications a breeze.
Motivation