Imagine a typical use-case when you have a list of items and an item view.
So there is an endpoint to get all items. But also you can fetch a single item with /items/:id.
But you can avoid fetching a single item if it's already fetched from the /items endpoint. So how would you handle that with react-query?
function Items() {
cosnt itemsQuery = useQuery('items', fetchItems);
// render items
}
function SingleItem({ id }) {
// you can have another query here and refetch item from server
// but how to reuse an item from query cache and fetch only if there is no such item?
}