Forked from antoineayoub/gist:c4d1a6fcacb105a9b83d997388c67bb2
Created
September 27, 2017 10:51
-
-
Save Guillaumejfrt/3248bc08c3bf7eb2cd7d21125691d15a to your computer and use it in GitHub Desktop.
redux_container_list_boilerplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import { bindActionCreators } from 'redux'; | |
| import { connect } from 'react-redux'; | |
| import { $ACTION } from '../actions'; | |
| class $LIST_CONTAINER extends Component { | |
| componentWillMount() { | |
| this.props.$ACTION(); | |
| } | |
| render(){ | |
| return( | |
| <div> | |
| { | |
| this.props.$LIST_KEY.map(($ITEM) => { | |
| return <$ITEM_CONTAINER key={$ITEM.id} item={$ITEM} /> | |
| } | |
| ) | |
| } | |
| </div> | |
| ) | |
| }; | |
| } | |
| function mapStateToProps(state) { | |
| return { | |
| $LIST_KEY: state.$LIST | |
| }; | |
| } | |
| function mapDispatchToProps(dispatch) { | |
| return bindActionCreators( | |
| { $ACTION }, | |
| dispatch | |
| ); | |
| } | |
| // export default $LIST_CONTAINER; | |
| export default connect(mapStateToProps, mapDispatchToProps)($LIST_CONTAINER); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment