javascript 错误:使用reactjs时元素类型无效[已关闭]

new9mtju  于 2023-04-19  发布在  Java
关注(0)|答案(1)|浏览(92)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
昨天关门了。
Improve this question
我得到了这个错误,我不明白这是什么意思。
服务器错误
错误:元素类型无效:需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:您可能忘记了从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。
生成页面时发生此错误。所有控制台日志都将显示在终端窗口中。

Call Stack renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6043:9) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderIndeterminateComponent file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5785:7) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5946:7) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderIndeterminateComponent file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5785:7) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5946:7) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderNode file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6259:12) renderChildrenArray file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6211:7) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6141:7) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5971:9) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderNode file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6259:12) renderChildrenArray file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6211:7) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6141:7) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5971:9) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderContextProvider file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5920:3) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6017:11) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderContextProvider file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5920:3) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6017:11) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderIndeterminateComponent file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5785:7) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5946:7) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderContextProvider file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5920:3) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6017:11) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderContextProvider file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5920:3) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6017:11) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderContextProvider file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5920:3) renderElement file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6017:11) renderNodeDestructiveImpl file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6104:11) renderNodeDestructive file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (6076:14) renderContextProvider file:///C:/Users/Kierian/Desktop/lol/node_modules/react-dom/cjs/react-dom-server.browser.development.js (5920:3)

尝试创建一个薄荷网站。

4ngedf3f

4ngedf3f1#

出现错误消息“元素类型无效:需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:“undefined”通常发生在React应用程序中,当你试图渲染一个没有正确定义或导出的组件时。

// ExampleComponent.js
import React from 'react';

const ExampleComponent = () => {
  // component logic here
};

export default ExampleComponent; // Make sure to include the export statement

相关问题