I’m getting an error called Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined in my newly built react-app after register and login which I’m unable to find the solution.
Here’s => the Working Demo
Seems like the error is for the private route
Please find the code piece below:
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 } }} />
)} />
)
Need Solution.
>Solution :
Looks like export issue
Please export he QuizPage like this
const connectedQuizPage = connect(mapStateToProps, mapDispatchToProps)(App);
export { connectedQuizPage as QuizPage };
