Created
January 23, 2018 14:56
-
-
Save themojilla/0529dd6a45ee0d0e8fbb4b9e38b3cf44 to your computer and use it in GitHub Desktop.
privateRoute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const PrivateRoute = ({component: Component, ...rest}) => ( | |
<Route {...rest} render={props => ( | |
localStorage.getItem('token') | |
? <Component {...props}/> | |
: <Redirect to={{ pathname: '/login', state: { from: props.location } }} /> | |
)} /> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment