SHARE
TWEET

Untitled

a guest Jun 15th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { connect } from "react-redux";
  2. import { bindActionCreators } from "redux";
  3. import { addProduct } from "../actions/addProduct";
  4.  
  5. const ProductListItem = ({ product }) => {
  6.   return (
  7.     <div className="product">
  8.       <img className="product_img" src={product.image} />
  9.       <p>{product.name}</p>
  10.       <p className="bold">$ {product.price}</p>
  11.       <button className="add_card" onClick={() => addProduct(product)}>
  12.         {" "}
  13.         add to cart
  14.       </button>
  15.     </div>
  16.   );
  17. };
  18.  
  19. export default ({ products = [] }) =>
  20.   products.map((product, i) => {
  21.     return <ProductListItem key={i} product={product} />;
  22.   });
  23.  
  24.  
  25. const mapDispatchToProps = dispatch => {
  26.   return bindActionCreators({ addProduct }, dispatch);
  27. };
  28.  
  29. connect(
  30.   mapDispatchToProps
  31. )(ProductListItem);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top