Skip to content

Instantly share code, notes, and snippets.

@tomanagle
Created May 16, 2017 12:38
Show Gist options
  • Save tomanagle/a318a8dc07913e28f71c4b6e79e548aa to your computer and use it in GitHub Desktop.
Save tomanagle/a318a8dc07913e28f71c4b6e79e548aa to your computer and use it in GitHub Desktop.
React Redux Container Component
import React, {PropTypes, Component} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
class $NAME extends Component {
constructor(props, context) {
super(props, context);
}
componentDidMount() {
document.title = $NAME;
}
render() {
return (
<div>
<h1>$NAME</h1>
</div>
);
}
}
$NAME.propTypes = {
//MyProps : PropTypes.objct.isRequired
};
//Return your props : state
function mapStateToProps(state, ownProps) {
return {};
}
// Bind action creators
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(actions, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)($NAME);
@tomanagle
Copy link
Author

Code Template for WebStorm.

File > Settings > Editor > File and Code Templates > Green plus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment