简体   繁体   English

定义了“标头”,但从未使用过未使用的变量

[英]'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.

相关问题 定义了“ stringValues”,但从未使用过no-unused-vars - “stringValues” is defined but never used no-unused-vars 'Home' 已定义但从未使用 no-unused-vars".* - 'Home' is defined but never used no-unused-vars".* 'UserInput' 已定义但从未使用过 no-unused-vars 'UserOutput' 已定义但从未使用过 no-unused-vars - 'UserInput' is defined but never used no-unused-vars 'UserOutput' is defined but never used no-unused-vars 组件已定义但从未使用 reactjs 中的 no-unused-vars 错误警告 - component is defined but never used no-unused-vars error warning in reactjs src\\App.js 'nav' 已定义但从未使用过 no-unused-vars - src\App.js 'nav' is defined but never used no-unused-vars 如何解决“错误'Vote'已定义但从未使用(no-unused-vars)”的问题? - How to solve the problem “error 'Vote' is defined but never used ( no-unused-vars)”? @typescript-eslint/eslint-plugin 错误:定义了“路由”但从未使用过(no-unused-vars) - @typescript-eslint/eslint-plugin error: 'Route' is defined but never used (no-unused-vars) 'inStock' 被赋值但从未使用过 no-unused-vars - 'inStock' is assigned a value but never used no-unused-vars 11:5 错误“路由器”被分配了一个值,但从未使用过 no-unused-vars - 11:5 error 'router' is assigned a value but never used no-unused-vars ESLint 抱怨从未使用过本地 state 变量 no-unused-vars - ESLint complains that a local state variable is never used no-unused-vars
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM