Created
July 6, 2016 14:05
-
-
Save lithin/7c6cc29337fb8c939a5356d45d03cf35 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, { PropTypes } from 'react'; | |
import { toJs } from 'mori'; | |
import { connect } from 'react-redux'; | |
// write this as a class component to leverage immutability of props for shouldComponentUpdate | |
const UserComponent = props => { | |
const user = toJs(props.user); | |
return (<div>Hi {user.name}!</div>); | |
} | |
UserComponent.propTypes = { | |
user: PropTypes.object.isRequired | |
}; | |
const mapStateToProps = state => ({ | |
user: state.user | |
}); | |
export default connect(mapStateToProps)(UserComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment