title: Counter variable issue with JavaScript
body: <p>In a React app, I got a state variable that's set to <code>0</code> at first.</p>
  <pre><code>const [amount, setAmount] = useState(0)
  </code></pre>
  <p>The functionality i'm looking for is to add/remover product in a redux store.</p>
  <p>So if a user presses a <code>&quot;+&quot;</code> button, it will check if <code>amount</code> is now bigger than <code>0</code>,
  and if so it'll <code>dispatch</code> an action to the store.
  But what I'm getting is that only after the second <code>&quot;+&quot;</code> press, when the value of <code>amount</code> is already <code>2</code>,
  the action is actually dispatched.
  This is the code :</p>
  <pre><code>const handleAmount = action =&gt; {
      if (action === 'plus') {
        setAmount(currAmount =&gt; currAmount + 1)
        updateStore()
      }
    }
  
  const updateStore = () =&gt; {
      if (amount &gt;= 1) {
        dispatch(addToCart(product))
      }
    }
  </code></pre>
  <p>What am I missing?</p>