Skip to content

Instantly share code, notes, and snippets.

@lithin
Last active July 12, 2016 10:21
Show Gist options
  • Save lithin/31e6ae559f3f0bd29064aad2e4dcc7b2 to your computer and use it in GitHub Desktop.
Save lithin/31e6ae559f3f0bd29064aad2e4dcc7b2 to your computer and use it in GitHub Desktop.
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