This is the config i have for eslint in .eslintrc.json
file:
{
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"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.
Try
class App extends Component {
Option 1: You don't need to import {Component} since you extends React.component and React is already imported.
Option 2: You can extend your App with Component instead of React.Component
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With