import React from 'react' ; import { Dispatch } from 'redux' ; import { connect } from 'react-redux' ; import ProductItem from '../components/ProductItem' ; import { AppStore , Product } from '../types' ; import { actions } from '../actions/constants' ; const mapStateToProps = ( state ) => ( { products : state . productsOldModule . products } ) ; const mapDispatchToProps = ( dispatch ) => { return { addItem : ( product ) => dispatch ( { type : actions . ADD_TO_CART_OLD , payload : product } ) } ; } ; const ProductListContainer = ( props ) => { const { products } = props ; return ( < > < h1 > This is the tried and trusty connect < /h1> < div > { products . map ( ( product ) => { return ( < ProductItem product = { product } key = { product . id } dispatchToStore = { props . addItem } / > ) ; } ) } < /div> < hr > < /hr> < />); } ; export default connect ( mapStateToProps , mapDispatchToProps ) ( ProductListContainer ) ;