# 'state' is not defined no-undef

**URL:** https://forum.codewithmosh.com/t/state-is-not-defined-no-undef/2943
**Category:** React
**Created:** [February 23, 2021, 12:16pm UTC](https://forum.codewithmosh.com/t/state-is-not-defined-no-undef/2943 "2021-02-23T12:16:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![B\_21](https://avatars.discourse-cdn.com/v4/letter/b/b782af/32.png) [@B\_21](https://forum.codewithmosh.com/u/B_21)
#### Post date: [February 23, 2021, 12:16pm UTC](https://forum.codewithmosh.com/t/state-is-not-defined-no-undef/2943/1 "2021-02-23T12:16:55Z")

</div>

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;

```

---

<div class="post-metadata">

### Author: ![herrifransisca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/herrifransisca/32/953_2.png) [@herrifransisca](https://forum.codewithmosh.com/u/herrifransisca)
#### Post date: [February 27, 2021, 1:57am UTC](https://forum.codewithmosh.com/t/state-is-not-defined-no-undef/2943/2 "2021-02-27T01:57:06Z")

</div>

the code seems okay for me.

are u still having this problem ?

I need more detail info
