From 7c6ee1d588820ee5a4dad079dbc6709711dd97ee Mon Sep 17 00:00:00 2001 From: Leon Xu Date: Thu, 5 May 2022 21:38:18 -0700 Subject: [PATCH] doc: add useStateValue and getBasketTotal --- src/Checkout/Subtotal.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Checkout/Subtotal.js b/src/Checkout/Subtotal.js index 5def393..a465bab 100644 --- a/src/Checkout/Subtotal.js +++ b/src/Checkout/Subtotal.js @@ -1,15 +1,18 @@ import React from "react"; import CurrencyFormat from "react-currency-format"; +import { useStateValue } from "../redux/StateProvider"; +import { getBasketTotal } from "../redux/reducer"; import "./Subtotal.css"; function Subtotal() { + const [{ basket }, dispatch] = useStateValue(); return (
( <>

- Subtotal (0 items): 0 + Subtotal ({basket.length} items): {value}

This order contains a gift @@ -17,7 +20,7 @@ function Subtotal() { )} decimalScale={2} - value={0} + value={getBasketTotal(basket)} displayType={"text"} thousandSeparator={true} prefix={"$"}