Skip to content

Instantly share code, notes, and snippets.

@clintonmedbery
Last active May 8, 2018 15:09
Show Gist options
  • Save clintonmedbery/ab5b692c5588c3d80fa83791c6f9b1ca to your computer and use it in GitHub Desktop.
Save clintonmedbery/ab5b692c5588c3d80fa83791c6f9b1ca to your computer and use it in GitHub Desktop.
ReactContainer Boilerplate
import React from 'react'
export const ThingComponent = ({ things, stuff}) => (
<Container>
<form>
</form>
</Container>
);
import React from 'react'
import { connect } from 'react-redux'
import { browserHistory } from 'react-router'
const mapStateToProps = (state, ownProps) => ({
thing: state.thing
});
const mapDispatchToProps = ({
setThing
});
const mergeProps = (stateProps, dispatchProps, ownProps) => ({
...stateProps,
...dispatchProps,
...ownProps,
functionWeWantOurComponenetToHave: (param) => {
//Do Something with param
}
});
class ThingContainerMixin extends React.Component {
constructor(props) {
super(props);
this.state = {
thing: ''
};
}
componentWillMount () {
};
componentWillUnmount () {
};
render () {
return (
<ThingComponent { ...this.props }
thing={this.state.thing}
/>;
};
}
const ThingContainer = connect(mapStateToProps, mapDispatchToProps, mergeProps)(ThingContainerMixin);
export default ThingContainer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment