title: Im having problems to understand the removeFromCart implementation in Redux shopping Cart example
body: <p>Im not sure where adn how implement the function removeProduct and how to define it..the basic idea is implement a removeProductFromCart functionality in the Redux shopping Cart example
  <a href="https://github.com/reduxjs/redux/tree/master/examples/shopping-cart" rel="nofollow noreferrer">https://github.com/reduxjs/redux/tree/master/examples/shopping-cart</a></p>
  
  <p>what I tried so far: </p>
  
  <p>action.js</p>
  
  <pre><code>           const deleteFromCart = productId =&gt; ({
                   type: types.REMOVE_PRODUCT,
                   productId
              })
  
             export const removeProduct = productId =&gt; (dispatch)=&gt; {
                    dispatch(deleteFromCart(productId))
              }
  </code></pre>
  
  <p>cartReducer.js</p>
  
  <pre><code>           const addedIds = (state = initState.addedIds, action) =&gt; {
                     switch (action.type) {
                         case ADD_PRODUCT:
  
                         if(state.indexOf(action.productId) !== - 1){
                               return state
                         }
                         return [ ...state, action.productId ]
  
                         case REMOVE_PRODUCT:
  
                             return state.filter(productId =&gt; action.productId !== productId)
  
                         default:
                             return state
                      }
                }
  
            const quantityById = (state = initState.quantityById, action ) =&gt; {
                    switch (action.type) {
                         case ADD_PRODUCT:
                    const { productId } = action
                    return {
                          ...state,
                          [productId]:(state[productId] || 0) + 1
                    }
                         case REMOVE_PRODUCT:
                    return { 
                          ...state,
                          [productId]: state[productId] - 1
                    } 
                       default:
                           return state
                    }
               }
  </code></pre>
  
  <p>Cart.js</p>
  
  <pre><code>     const Cart = ({products, total, onCheckoutClicked, 
       onDeleteFromCart }) =&gt; {
  
       const hasProducts = products.length &gt; 0
  
       const nodes = hasProducts ? (
  
       products.map(product =&gt;
  
           &lt;div key={product.id}&gt;
  
              &lt;Product
               titulo={product.titulo}
               price={product.price}
               quantity={product.quantity}
               /&gt;
              &lt;button
               onClick={onDeleteFromCart}
               disabled={product.inventory &lt; 0 ? 'disabled' :'' }&gt;
              {product.inventory &lt; 0 ? 'Sin productos' : 'Sacar del carrito'}
               &lt;/button&gt;
  
            &lt;/div&gt;
           )
         ):(&lt;p&gt;Agregá productos al carrito&lt;/p&gt;)
  
         return (
              &lt;div&gt;
                  &lt;h3&gt;Tu Carrito&lt;/h3&gt;
                  &lt;div&gt;{nodes}&lt;/div&gt;
                  &lt;p&gt;Total: &amp;#36;{total}&lt;/p&gt;
                  &lt;button onClick={onCheckoutClicked} disabled={hasProducts ? '' : 'disabled'}&gt;Checkout&lt;/button&gt;
               &lt;/div&gt;
                  )      
                 }
  
            Cart.propTypes = {
             products:PropTypes.array,
             total:PropTypes.string,
             onCheckoutClicked:PropTypes.func,
             onDeleteFromCart:PropTypes.func
        }
  
      export default  Cart
  </code></pre>
  
  <p>CartContainer.js</p>
  
  <pre><code>const CartContainer = ({products, total, checkout, removeProduct}) =&gt; (
  
    &lt;Cart
       products={products}
       total={total}
       onCheckoutClicked={()=&gt;checkout(products)}
       onDeleteFromCart={()=&gt;removeProduct(products.map(product =&gt; product.id))}
    /&gt;
  )
  
  CartContainer.propTypes = {
    products: PropTypes.arrayOf(PropTypes.shape({
      id:PropTypes.number.isRequired,
      titulo: PropTypes.string.isRequired,
      price: PropTypes.number.isRequired,
      quantity: PropTypes.number.isRequired
    })).isRequired,
    total:PropTypes.string,
    checkout:PropTypes.func.isRequired,
    removeProduct:PropTypes.func.isRequired
  }
  
  const mapStateToProps = (state) =&gt; ({
    products: getCartProducts(state),
    total: getTotal(state)
  })
  
  export default connect(
    mapStateToProps,
    { checkout, removeProduct }
  )(CartContainer)
  </code></pre>
  
  <p>this code returns an array when I dispatch the action REMOVE_PRODUCT...
  so I don't end to understand how I can make it works..the code don't trows error but how can I retrun just the id of the product? and not the array..its correct implement the functionality in CartContainer and cart? ...makes sense to my...but I seen some code where the implemntation is in productitems.js</p>
  
  <p>Thanks in advance</p>