title: How to update the display using .map function in React.js
body: <p>I have a useState variable that holds log data and I'm displaying that data using <code>.map()</code>, at some particular moment, logs will be added, and I take the old variable and re affect the new value for it as the following :</p>
  <pre><code>const [logs, setLogs] = useState([])
  
  const function1 = () =&gt; {
  // some process here
   setLogs(myValues)
  }
  const function2 = () =&gt; {
  // some process
  let myNewValues = logs
  // some other process
  setLogs(myNewValues)
  }
  </code></pre>
  <p>.map() function displays the <code>logs</code> just fine after the first function, but when I update the logs with <code>setLogs</code> in the second function, <code>.map()</code> doesn't get the update, it displays the old values from function1.</p>
  <p>How can I fix this in react ?</p>
  <p>Thanks in adavance !</p>