Home > Back-end >  Element type is invalid: expected a string (for built-in components) or a class/function (for compos
Element type is invalid: expected a string (for built-in components) or a class/function (for compos

Time:01-24

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 enter image description here

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.

CodePudding user response:

Looks like export issue Please export he QuizPage like this

const connectedQuizPage = connect(mapStateToProps, mapDispatchToProps)(App);
export { connectedQuizPage as QuizPage };

  •  Tags:  
  • Related