-
Notifications
You must be signed in to change notification settings - Fork 113
Closed
Description
I commend this library because it saves a lot of new users from having to be forced to learn redux just to cater to this router issue.
My issue is because I created a functional component called ProtectedRoute where it returns the CacheRoute or a redirect if the user is not authenticated.
I place the ProtectedRoute tag in the CacheSwitch but it does not work. any idea what could be wrong with this code? Thank you
const ProtectedRoute = (props) => {
return localStorage.getItem('user') !== null
? <CacheRoute {...props} />
: <Redirect to="/login"/>;
};
export default ProtectedRoute;
And this is the cache switch
<CacheSwitch>
<ProtectedRoute component={MyComponent} path="/" exact/>
</CacheSwitch>
Metadata
Metadata
Assignees
Labels
No labels