Show different data when navigating to another page (useQuery)

ds1989126 注册会员
2023-01-25 22:47

..query key should be created out of everything that the queryFn uses. In your case, that would only be the boxId:

useQuery(['inventorky', boxID], () => getInventoryItemsForCardsInBox(boxID))

then, you'll have one cache entry per boxID, which corresponds to your endpoints.

I didn't quite understand the issue about sets of boxes, but it shouldn't matter what you do with the query. The resource is the box, and that's why you cache it by the boxID.