'totalCart' is always 0 when use multiple carts
nachoaldamav opened this issue · comments
Nacho Aldama commented
I'm trying to add multiple carts to my website, one per "pack", the problem is that i can't use cartTotal
.
/pages/pack/[id].js
import { CartProvider,} from "react-use-cart";
import CartComponent from "../../components/CartComponent";
export default function PackPage({ data }) {
return (
<CartProvider id={data.seller.id}>
... Render the page component
<CartComponent />
</CartProvider>
)
}
/components/CartComponent/
import { useCart } from "react-use-cart";
export default function CartComponent() {
const { cartTotal } = useCart();
return (
<div>
<h4>{cartTotal}€</h4> // This is always 0
</div>
);
}
Nacho Aldama commented
Somehow it works now! sorry for the issue! 😂
PS: If you have this error try moving the cartTotal to another component!