How to approach cross dependencies between data types? #2606
Unanswered
leandertolksdorf
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Assume you have two endpoints, for example:
/items
sending:[{ "id" : 1, "name" : "MacBook" }]
/carts
sending:[{ "id" : 1, "itemIds" : [ 1 ] }]
We create
useItems()
like:const useItems = () => useSWR("/items")
and
useCarts()
like:Let someone now mutate the item with id 1, for example changing the name.
useItem() gives us the correct data after revalidation, but useCarts still has the old data.
What's the best way to handle such common cases of dependent data?
Beta Was this translation helpful? Give feedback.
All reactions