Skip to content

Instantly share code, notes, and snippets.

@mattiamanzati
Created February 29, 2016 08:54
Show Gist options
  • Save mattiamanzati/509617a491ef50b94d5a to your computer and use it in GitHub Desktop.
Save mattiamanzati/509617a491ef50b94d5a to your computer and use it in GitHub Desktop.
import {getLoggedUser} from './selectors';
class LoggedUserName extends React.Component{
render(){
return this.props.user ? <p>{this.props.user.username}</p> : <p>Anonymous Cow</p>;
}
}
function mapStateToProps(state){
return {
user: getLoggedUser(state)
};
}
LoggedUserName = connect(mapStateToProps)(LoggedUserName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment