title: React + useState() + previousState
body: <p>I am quite new to react and have problems in understanding the useState Hook - or more specifically the aspect of the <em>previousState</em>.</p>
  <p>A normal useState Hook, and probably most common example, looks like this:</p>
  <pre><code>import React, { useState} from 'react';
  
  export default function CounterHooks({ initialCount }){
    const [count, setCount] = useState(initialCount);
  
    return (
      &lt;div&gt;
        &lt;button onClick={() =&gt; setCount(count -1)}&gt;-&lt;/button&gt;
        &lt;span&gt;{count}&lt;/span&gt;
        &lt;button onClick={() =&gt; setCount(count + 1)}&gt;+&lt;/button&gt;
      &lt;/div&gt;
    )
  }
  </code></pre>
  <p>What I am understanding so far, is the following:</p>
  <ul>
  <li>I call the useState() function/Hook? and pass in the argument of the initial State (initialCount)</li>
  <li>I get back an array which i immediately destruct into the variables count and setCount (which
  is function)</li>
  <li>With setCount() i can update the state and therefore the count variable</li>
  </ul>
  <p>So far so good, i think... ;)</p>
  <p>Sometimes I see the same counter example with prevState (prevCount) which i do not understand:</p>
  <pre><code>&lt;button onClick={() =&gt; setCount(prevCount =&gt; prevCount -1)}&gt;-&lt;/button&gt;
  </code></pre>
  <p>What happens here? This part i do not understand.
  My thoughts so far:</p>
  <ul>
  <li>In this case, I somehow access the previous count value.</li>
  <li>setCount expects now a function</li>
  <li>setCount is now run asynchron</li>
  <li>Where is this function coming from?</li>
  <li>Where is prevCount coming from?</li>
  <li>When i run this, what is put into prevCount?</li>
  </ul>
  <p>Do you understand my confusion? I am not sure how i should frame this differently...</p>
  <p>Thank you very much for your help.</p>