lifecycle event state and prevState in react.js
<p>Below is a simple counter in react. But I have 3 questions. </p>

<ol>
<li><p>What is state in line 3? It looks like a global variable, it would make sense if it has <code>var</code> or <code>const</code> before it. Is that a lifecycle function/var?</p></li>
<li><p>Do I have to import Component from react? I remember I did not need do that in v15.</p></li>
<li><p>Where does prevState come from?</p></li>
</ol>

<blockquote>
<pre><code>import React, { Component } from 'react';

class Counter extends Component {
  state = { value: 0 };

  increment = () =&gt; {
    this.setState(prevState =&gt; ({
      value: prevState.value + 1
    }));
  };

  decrement = () =&gt; {
    this.setState(prevState =&gt; ({
      value: prevState.value - 1
    }));
  };

  render() {
    return (
      &lt;div&gt;
        {this.state.value}
        &lt;button onClick={this.increment}&gt;+&lt;/button&gt;
        &lt;button onClick={this.decrement}&gt;-&lt;/button&gt;
      &lt;/div&gt;
    )
  }
}
</code></pre>
</blockquote>