Skip to content

Commit

Permalink
useSelectorでstoreにアクセスして表示してみよう
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yoshiii committed Sep 1, 2022
1 parent f3010c1 commit 9d1d789
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/Navbar.js
@@ -1,14 +1,17 @@
import React from "react";
import { useSelector } from "react-redux";

const Navbar = () => {
const { amount } = useSelector((store) => store.cart);
console.log(amount);
return (
<nav>
<div className="nav-center">
<h3>Redux Shopping</h3>
<div className="nav-container">
ロゴ
<div className="amount-container">
<p className="total-amount">0</p>
<p className="total-amount">{amount}</p>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/features/cart/CartSlice.js
Expand Up @@ -2,7 +2,7 @@ import { createSlice } from "@reduxjs/toolkit/";

const initialState = {
cartItems: [],
amout: 0,
amount: 4,
total: 0,
};
const cartSlice = createSlice({
Expand Down

0 comments on commit 9d1d789

Please sign in to comment.