简体   繁体   English

元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义的组件问题

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

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.我收到一个错误,称为Element type is invalid: expected a string (for built-in components) or a class/function (for Composite Components) but got: undefined in my new build react-app after register and login which I'我无法找到解决方案。

Here's => the Working Demo这是 => 工作演示

and the screen和屏幕在此处输入图像描述

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.需要解决方案。

Looks like export issue Please export he QuizPage like this看起来像导出问题 请像这样导出他的 QuizPage

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NextJS:元素类型无效:期望字符串(用于内置组件)或类/函数(用于复合组件)但得到:未定义 - NextJS: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 元素类型无效:预期字符串(用于内置组件)或类/函数(用于复合组件)但得到:未定义 - Element type is invalid: expected string (for built-in components) or a class/function (for composite components) but got: undefined 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 渲染错误元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义 - Render Error Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件),但得到:未定义 - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 控制台错误:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义 - Console error: Element type is invalid:expected a string (for built-in components) or a class/function (for composite components) but got: undefined ReactDOM - 元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - ReactDOM - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined React - 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - React - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 错误 - 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - error - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义。 在 nextjs 中 - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. in nextjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM