Last active
May 16, 2017 19:06
-
-
Save nesbtesh/96b37b8b9d6997359a90fc7cae31523d to your computer and use it in GitHub Desktop.
Parent container in React Redux
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
class Container extends React.Component { | |
render(){ | |
const { props } = this; | |
return( | |
<div className="main-content"> | |
{ | |
React.Children.map(this.props.children, function(child) { | |
return React.cloneElement( | |
child, | |
{ ...props } | |
); | |
}) | |
} | |
</div> | |
); | |
} | |
} | |
const mapStateToProps = (state) => { | |
return state; | |
}; | |
function mapDispatchToProps(dispatch) { | |
return { | |
actions: bindActionCreators(actions, dispatch) | |
}; | |
} | |
export default connect( | |
mapStateToProps, | |
mapDispatchToProps | |
)(Container); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The indentation is kind of weird, also I recommend using
const
overvar
.