Advertisement
rodrigofbm

component

Dec 16th, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2. import { connect } from "react-redux";
  3. import "./cart-icon.styles.scss";
  4.  
  5. import { ReactComponent as ShoppingIcon } from "../../assets/11.2 shopping-bag.svg.svg";
  6. import { toggleCartHidden } from "../../redux/cart/cart.actions";
  7. import { selectCartItemsCount } from "../../redux/cart/cart.selectors";
  8.  
  9. const CartIconComponent = ({ toggleCartHidden, itemCount }) => (
  10.   <div className="cart-icon" onClick={toggleCartHidden}>
  11.     <ShoppingIcon className="shopping-icon" />
  12.     <span className="item-count">{itemCount}</span>
  13.   </div>
  14. );
  15.  
  16. const mapDispatchToProps = dispatch => ({
  17.   toggleCartHidden: () => dispatch(toggleCartHidden())
  18. });
  19.  
  20. const mapStateToProps = state => {
  21.   console.log("invocado"); //continua invocando
  22.   return {
  23.     itemCount: selectCartItemsCount(state)
  24.   };
  25. };
  26.  
  27. export default connect(mapStateToProps, mapDispatchToProps)(CartIconComponent);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement