简体   繁体   English

React Native 错误:元素类型无效:应为字符串或类/函数,但得到:未定义

[英]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 文件中,根据错误和错误消息,问题来自哪里。

Error Message Picture错误信息图片

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.

相关问题 React Native 错误:元素类型无效:应为字符串或类/函数(对于复合组件)但得到:未定义 - React Native Error: Element type is invalid: expected a string or a class/function (for composite components) but got: undefined React Native - “元素类型无效:需要字符串或类/函数但未定义” - 导入自定义库? - React Native - “Element type is invalid: expected a string or a class/function but got undefined” - importing custom library? 世博反应本机元素类型无效:预期为字符串或类/函数,但得到:未定义 - Expo react native Element type is invalid: expected a string or a class/function but got: undefined React Native 错误:元素类型无效:应为字符串或类/函数,但得到:未定义。 但是哪里? - React Native Error: Element type is invalid: expected a string or a class/functionbut got: undefined. But where? 错误:缩小的 React 错误 #130:元素类型无效:预期为字符串或类/函数,但得到:未定义 - Error: Minified React error #130: Element type is invalid: expected a string or a class/function but got: undefined 反应错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义 - React Error: 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 创建React Native应用程序时出错:元素类型无效:预期为字符串或类/函数,但得到了:对象 - Error when creating React Native app: Element type is invalid: expected a string or a class/function but got: object React Native 错误:元素类型无效:需要字符串或类/函数,但得到:object - React Native error: Element type is invalid: expected a string or a class/function but got: object React Native Element类型无效,预期字符串但未定义 - React Native Element type is invalid expected a string but got undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM