doc" add useStateValue to Header component to change the hardcode value to dynamic value
This commit is contained in:
1 parent
872938bdd1
commit
27462887ac
1 file changed
+6
-1
@@ -2,8 +2,11 @@ import React from "react";
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { Search, ShoppingCart } from "@material-ui/icons";
|
import { Search, ShoppingCart } from "@material-ui/icons";
|
||||||
import "./Header.css";
|
import "./Header.css";
|
||||||
|
import { useStateValue } from "../redux/StateProvider";
|
||||||
|
|
||||||
function Header() {
|
function Header() {
|
||||||
|
const [{ basket }, dispatch] = useStateValue();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="header">
|
<header className="header">
|
||||||
<Link to="/">
|
<Link to="/">
|
||||||
@@ -36,7 +39,9 @@ function Header() {
|
|||||||
<Link to="/checkout">
|
<Link to="/checkout">
|
||||||
<section className="header__optionBasket">
|
<section className="header__optionBasket">
|
||||||
<ShoppingCart />
|
<ShoppingCart />
|
||||||
<span className="header__optionLineTwo header__basketCount">0</span>
|
<span className="header__optionLineTwo header__basketCount">
|
||||||
|
{basket?.length}
|
||||||
|
</span>
|
||||||
</section>
|
</section>
|
||||||
</Link>
|
</Link>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
Reference in new issue
Block a user