Skip to content

Instantly share code, notes, and snippets.

@jepras
Created October 5, 2018 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jepras/3432d62acb4606503895c2d3e1d1842c to your computer and use it in GitHub Desktop.
Save jepras/3432d62acb4606503895c2d3e1d1842c to your computer and use it in GitHub Desktop.
If isAuthenticated, then render component. If not redirect to login.
const SecretRoute = ({ component: Component, ...rest }) => (
<Route {...rest} render={(props) => (
AuthService.isAuthenticated === true
? <Component {...props} />
: <Redirect to='/login' />
)} />
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment