SHARE
TWEET

Untitled

a guest Jun 15th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { bindActionCreators } from "redux";
  2. import { addProduct } from "../actions/addProduct";
  3.  
  4. const ProductListItem = ({ product }) => {
  5.   return (
  6.     <div className="product">
  7.       <img className="product_img" src={product.image} />
  8.       <p>{product.name}</p>
  9.       <p className="bold">$ {product.price}</p>
  10.       <button className="add_card" onClick={() => addProduct(product)}>
  11.         {" "}
  12.         add to cart
  13.       </button>
  14.     </div>
  15.   );
  16. };
  17.  
  18. export default ({ products = [] }) =>
  19.   products.map((product, i) => {
  20.     return <ProductListItem key={i} product={product} />;
  21.   });
  22.  
  23.  
  24. const mapDispatchToProps = dispatch => {
  25.   return bindActionCreators({ addProduct }, dispatch);
  26. };
  27.  
  28. connect(
  29.   mapDispatchToProps
  30. )(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