I don't understand this error in React. Possible export error?

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

You should upload your picture to imgur or directly to the forums by dragging and dropping it into the editor box.

1 Like