Subscribe to specific key changes
In an e-commerce site, I have a cart that gets fetched on every page (globally).
I’d like to avoid a useCartQuery() hook on something like the cart icon that only needs to update on a single “itemQuantity” property.
I come across this issue on many other instances too where I have a component that only needs to render on a specific item change and not the entire cart.
Is there a react-query way of doing this? Can I sync cart with another store that supports selective updates (nanostores/zustand)?
I’d also like to avoid prop drilling, and hopefully context.
I’d like to avoid a useCartQuery() hook on something like the cart icon that only needs to update on a single “itemQuantity” property.
I come across this issue on many other instances too where I have a component that only needs to render on a specific item change and not the entire cart.
Is there a react-query way of doing this? Can I sync cart with another store that supports selective updates (nanostores/zustand)?
I’d also like to avoid prop drilling, and hopefully context.