Last active
September 28, 2017 15:43
-
-
Save antoineayoub/c4d1a6fcacb105a9b83d997388c67bb2 to your computer and use it in GitHub Desktop.
redux_container_list_boilerplate
This file contains 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