[英]component is defined but never used no-unused-vars error warning in reactjs
import React from "react";
import navBar from "./components/navBar/navBar"; //navBar is imported here
function App() {
return (
<>
<div className="App">
<navBar /> //navBar is used here
</div>
</>
);
}
export default App;
I changed the eslint.我改变了eslint。 But no use and tried some stackoverflow solutions but no change.
但没有用并尝试了一些 stackoverflow 解决方案但没有改变。
In JSX, lower-case tag names are considered to be HTML tags.在 JSX 中,小写的标签名称被认为是 HTML 标签。
So you can change the component name to NavBar, or while importing you can write import NavBar from "./components/navBar/navBar"; //navBar is imported here
因此,您可以将组件名称更改为 NavBar,或者在导入时您可以编写
import NavBar from "./components/navBar/navBar"; //navBar is imported here
import NavBar from "./components/navBar/navBar"; //navBar is imported here
install npm install --save-dev eslint-plugin-react.
安装
npm install --save-dev eslint-plugin-react.
Then, add this to .eslintrc.json
, under extends然后,将其添加到
.eslintrc.json
的 extends 下
'extends': [
'plugin:react/recommended'
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.