import React, { Component } from 'react'
import { connect } from 'react-redux'

import ProductsList from '../../views/ProductList'
import { addProduct, deleteProduct } from '../../../redux/modules/products/actions'

class ProductListContainer extends Component {

    _doAddProduct = function() {
        let id = Math.floor(Math.random() * (100 - 5) + 5);
        this.props.addProduct({'id': id, 'description': 'product ' + id})
    }

    _doDeleteProduct = function(product) {
        this.props.deleteProduct(product.id)
    }

    render() {
        return (<ProductsList title="My Products"
                              products={ this.props.products }
                              addProduct={ this._doAddProduct.bind(this) }
                              deleteProduct={ this._doDeleteProduct.bind(this) }></ProductsList>)
    }
}

function mapStateToProps(state) {
    return {products: state.products.itemList}
}

export default connect(mapStateToProps, {addProduct, deleteProduct})(ProductListContainer)

@@ -209,16 +209,132 @@
 tions'%0A%0A
+@connect((state) =%3E %7B%0A    return %7Bproducts: state.products.itemList%7D%0A%7D, %7BaddProduct, deleteProduct%7D)%0Aexport default 
 class Pr
@@ -955,180 +955,4 @@
 %7D%0A%7D%0A
-%0Afunction mapStateToProps(state) %7B%0A    return %7Bproducts: state.products.itemList%7D%0A%7D%0A%0Aexport default connect(mapStateToProps, %7BaddProduct, deleteProduct%7D)(ProductListContainer)%0A

use decorator syntax to connect redux to container