Skip to content

Instantly share code, notes, and snippets.

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