Skip to content

Instantly share code, notes, and snippets.

@williamtran29
Forked from slightlytyler/withAuth.js
Created July 24, 2017 09:48
Show Gist options
  • Save williamtran29/d3fe18ee044118c154704f0f3f0fe6d5 to your computer and use it in GitHub Desktop.
Save williamtran29/d3fe18ee044118c154704f0f3f0fe6d5 to your computer and use it in GitHub Desktop.
import { compliment, compose, get } from 'lodash/fp';
import { connect } from 'react-redux';
import { branch, renderComponent } from 'recompose';
const selectIsAuthenticated = state => ({
isAuthenticated: Boolean(state.currentUser),
});
const withAuth = compose(
connect(selectAuthorizationStatus),
branch(
compose(compliment, get)('isAuthenticated'),
renderComponent(Login),
),
);
export default withAuth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment