Closed nachoaldamav closed 3 years ago
I'm trying to add multiple carts to my website, one per "pack", the problem is that i can't use cartTotal.
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> ); }
Somehow it works now! sorry for the issue! 😂
PS: If you have this error try moving the cartTotal to another component!
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
/components/CartComponent/