I’m practicing in React JS. I made the elementary counter through a class.
import React from 'react';
class ClassCounter extends React.Component {
construct(){
super();
this.state = {
count: 0
}
}
incriment() {
this.setState({this.state.count + 1})
}
decrement() {
this.setState({this.state.count - 1})
}
render() {
return (
<div>
<h2>{this.count}</h2>
<button type="button" onClick={this.incriment}>Incriment</button>
<button type="button" onClick={this.decrement}>Decrement</button>
</div>
)
}
}
Everything seems to be working. But my project has ESlint.
And it throws the following errors
- appears before super() – “super() call outside constructor of a subclass eslint”
- appears after this {this.state.count + 1} – “Expected “:”.ts(1005)” (I think this error comes out of the first one.)
Here is .json
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"airbnb"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
}
I have already read literaly everything, the only hope is your help guys.