Hello everyone
I am trying to make a private route with reactjs and router-router-dom to redirect users if they are not authenticated. But upon compiling I get the following error:
I believe the error is realating to the way I exported it but IDK
Anyways here is my code:
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
export const PrivateRoute = ({ component: Component, ...rest }) => (
<Route {...rest} render={props => (
localStorage.getItem('user')
? <Component {...props} />
: <Redirect to={{ pathname: '/login', state: { from: props.location } }} />
)} />
)
export default PrivateRoute;
Any suggestions? Thank you in advance!
Liam