Skip to content

Instantly share code, notes, and snippets.

@lithin
Created July 6, 2016 14:05
Show Gist options
  • Save lithin/7c6cc29337fb8c939a5356d45d03cf35 to your computer and use it in GitHub Desktop.
Save lithin/7c6cc29337fb8c939a5356d45d03cf35 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