title: updating a state immediately using react hooks
body: <p>I am trying to update a state after a trigger and want to use the state immediately for a function to trigger but the state is not updated immediately .</p>
  
  <p>any suggestions ?</p>
  
  <pre><code>                 &lt;Button
                         onClick={() =&gt; {
                          console.log(finalData) //old data
                         setFinalData(mutableData); // updating state
                          console.log(finalData) // still geeting old state
                 }&gt;
             &lt;/Button&gt;
  </code></pre>