[英]React Native error! Element type is invalid: expected a string or a class/function but got: undefined
I am a junior in my advanced front web development class and we just started learn react.我是我高级前线 web 开发 class 的大三学生,我们刚刚开始学习反应。 I am fairly new to React and struggling with this error.
我对 React 还很陌生,并且正在努力解决这个错误。 I am building an e-commerce website for my final project and I am using @moltin/sdk with React and Redux through create-react-app so I dont have the webpack config.
我正在为我的最终项目构建一个电子商务网站,并且我正在通过 create-react-app 将 @moltin/sdk 与 React 和 Redux 一起使用,因此我没有 webpack 配置。 My codes complied successfully, however, I am getting this error:
我的代码成功编译,但是,我收到此错误:
Blockquote Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Blockquote 错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。 You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
您可能忘记从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。
I am not sure what is it wrong.我不确定这是怎么回事。 I checked all my components and have export default for each of them in their own respective file since export default is limited to one per document.
我检查了所有组件,并在各自的文件中为每个组件设置了导出默认值,因为导出默认值仅限于每个文档一个。 Any help would be greatly appreciated, I have included by index.js file which where the issues is coming from according to the error and the error message.
任何帮助将不胜感激,我已经包含在 index.js 文件中,根据错误和错误消息,问题来自哪里。
import React from 'react';
import {render} from 'react-dom';
import './index.css';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
import App from '../src/component/App.js';
import store, { history } from './store';
const target = document.getElementById('root');
render(
<Provider store={store}>
<ConnectedRouter history={history}>
<div>
<App />
</div>
</ConnectedRouter>
</Provider>, target
);
This is on React ^16.13.1, react-redux ^7.2.0, and redux ^4.0.5.这是在 React ^16.13.1、react-redux ^7.2.0 和 redux ^4.0.5 上。 Thank you again!
再次感谢你!
import { ConnectedRouter } from 'connected-react-router'
This is the actual import for Connected Router.这是连接路由器的实际导入。
connected-react-router
is the library used for Redux binding for React Router. connected-react-router
是用于 React Router 的 Redux 绑定的库。 Install this package with the below command.使用以下命令安装此 package。
npm install --save connected-react-router
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.