TanStackT
TanStack2y ago
3 replies
awake-maroon

useInfiniteQuery cache for useQuery

Best explained by example

website.com/todos/
Show all todos with useInfiniteQuery , results are stored in cache
const queryKey = ['todos']


website.com/todos/{todoId}
Show a specific todo with
useQuery

const queryKey = ['todo', todoId]


Since the keys are different (as infinite query stores a page of data), how might we be able to update the cache manually for the single todo cache?

It seems silly to fetch a list of 10 items and then additionally fetch the same 10 items individually as they are clicked on when we already have them.
Was this page helpful?