{"size": 1287, "ext": "js", "max_stars_repo_path": "src/containers/products-list.js", "max_stars_repo_name": "ukvaddi/MicroFrontendPOC", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/containers/products-list.js", "max_issues_repo_name": "ukvaddi/MicroFrontendPOC", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/containers/products-list.js", "max_forks_repo_name": "ukvaddi/MicroFrontendPOC", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.9782608696, "max_line_length": 96, "alphanum_fraction": 0.6231546232}
import React ,{Component} from 'react';
import {connect} from 'react-redux';

import {bindActionCreators} from 'redux';
import * as actions from '../actions/index';

 class ProductsList extends Component{
    
    renderList(){
       console.dir(this.props.products);
        return this.props.products.map((product)=>{
            return (
                <li onClick={() => this.props.selectProduct(product) }
                    key={product.title} 
                    className="list-group-item">{product.title}</li>
            );
        });
    }
   
    render(){
        
       return (
           <ul className="list-group col-sm-4">
                {this.renderList()}
        
            </ul>   
        );
    }
}



function mapStatetoProps(state){
    //whatever returned will show up as props of this class i.e productsList
    return {
        products:state.products
    };
}

//anything which is returned from this function will end up as props  on the booklist container
function mapDispatchToProps(dispatch){
    //whenever selectBook action is called,the result should be passed to passed to all reducers
    return bindActionCreators({selectProduct:actions.selectProduct},dispatch);
}

export default connect(mapStatetoProps,mapDispatchToProps)(ProductsList);