'state' is not defined no-undef

Hey! I keep getting the error and I am not quite sure what’s going on or how to fix it (I’m very new to React and JS).

Error:

src\components\counter.jsx Line 4:3: ‘state’ is not defined no-undef Search for the keywords to learn more about each error.

Code:

import React, { Component } from "react";

class Counter extends Component {

  state = {

    count: 0,

  };

  render() {

    return (

      <React.Fragment>

        <span>{this.state.count}</span>

        <button>Increment</button>

      </React.Fragment>

    );

  }

}

export default Counter;

the code seems okay for me.

are u still having this problem ?

I need more detail info

1 Like