元素类型无效:应为字符串(对于内置组件)或 class/function(对于复合组件)但得到:未定义的组件问题

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined component issue

我收到一个名为 Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 在注册和登录后新建的 react-app 中,我无法找到解决方案。

这里是 => Working Demo

和屏幕

似乎是私有路由的错误

请找到下面的代码片段:

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 } }} />
    )} />
)

需要解决方案。

看起来像是导出问题 请像这样导出他的 QuizPage

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