admin管理员组文章数量:1244247
This is the config i have for eslint in .eslintrc.json
file:
{
"env": {
"browser": true,
"monjs": true,
"es6": true
},
"extends": "eslint:remended",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": ["error"],
"indent": 0,
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
},
"settings": {
"react": {
"pragma": "React",
"version": "15.0"
}
}
}
This is the app.jsx
from the react workspace below:
import React, { Component } from 'react';
class App extends React.Component {
render () {
return(
<h1>Hello Newbies</h1>
);
}
}
export default App;
I am getting error from eslint 'Component' is defined but never used.
I can not fix this by doing anything so far but digging the web. How can i fix this error? Help would be very much appreciated.
This is the config i have for eslint in .eslintrc.json
file:
{
"env": {
"browser": true,
"monjs": true,
"es6": true
},
"extends": "eslint:remended",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": ["error"],
"indent": 0,
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
},
"settings": {
"react": {
"pragma": "React",
"version": "15.0"
}
}
}
This is the app.jsx
from the react workspace below:
import React, { Component } from 'react';
class App extends React.Component {
render () {
return(
<h1>Hello Newbies</h1>
);
}
}
export default App;
I am getting error from eslint 'Component' is defined but never used.
I can not fix this by doing anything so far but digging the web. How can i fix this error? Help would be very much appreciated.
3 Answers
Reset to default 5Try
class App extends Component {
Option 1: You don't need to import {Component} since you extends React.ponent and React is already imported.
Option 2: You can extend your App with Component instead of React.Component
Just remove "import React, { Component } from 'react';" this line and warning will be resolved as this will be not used in functional based Components.
本文标签: javascriptHow to fix quotComponent is defined but never usedquot for eslint in reactStack Overflow
版权声明:本文标题:javascript - How to fix "Component is defined but never used" for eslint in react? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740204293a2240784.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论