[英]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这是 => 工作演示
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.