作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是reactjs新手。我创建了一个应用程序并尝试在 app.js 中加载 header 组件。当我尝试加载 header 组件时,它在命令提示符中显示抛出警告错误,如
./src/components/Header.jsx
Line 2 'Header' is defined but never used no-unused-vars
当我运行应用程序时,也会在浏览器中引发错误
React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
在 App.js:24 检查您的代码
我在根目录中添加了一个文件“.eslintrc”,并向其中添加了以下代码
{
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
}
}
到目前为止,没有任何效果。谁能帮我解决这个问题吗?
最佳答案
请将Header.jsx
重命名为Header.js
请务必将以下代码行放在您的 App.js 之上:
import {Header} from '/src/components/Header.jsx'
务必将export
放在class Header {..}
希望有帮助;-)
关于javascript - 已定义“ header ”但从未使用过 no-unused-vars,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44631405/
背景 我最近在 merge 期间遇到了一个意外未 merge 的文档文件的问题。 无论出于何种原因,我搞砸了 merge 并有效地删除了文件(和其他几个文件),因为我忘记了它们的存在。 现在我想查看我
我在我的网站上使用旧的 mysql 版本和 php 版本 4。 我的表结构: | orders_status_history_id | orders_id | orders_status_id |
我是一名优秀的程序员,十分优秀!