[英]'Header' is defined but never used no-unused-vars
I am new to reactjs. 我是Reactjs的新手。 I have created a application and trying to load header component inside the app.js.
我创建了一个应用程序,并尝试在app.js中加载标头组件。 When i try to load the Header component it show throws warning error in command prompt as
当我尝试加载Header组件时,显示为在命令提示符下引发警告错误,如下所示:
./src/components/Header.jsx
Line 2 'Header' is defined but never used no-unused-vars
Also throws error in the browser when i run the application 当我运行应用程序时,也会在浏览器中引发错误
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.
Check your code at App.js:24 在App.js上检查代码:24
I have added a file ".eslintrc" in the root and added below code to that 我在根目录中添加了文件“ .eslintrc”,并在其下面添加了以下代码
{
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
}
}
So far nothing works. 到目前为止,没有任何效果。 Can anyone please help me on this.
谁能帮我这个忙。
Please rename Header.jsx
to Header.js
请将
Header.jsx
重命名为Header.js
Be sure to put following line of code on top of your App.js: 确保将以下代码行放在App.js之上:
import {Header} from '/src/components/Header.jsx'
be sure to put export
in front of class Header {..}
确保将
export
放在class Header {..}
前面
Hope that helps ;-) 希望有帮助;-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.