Last active
July 12, 2016 10:21
-
-
Save lithin/31e6ae559f3f0bd29064aad2e4dcc7b2 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