title: why useState return empty array in react.js?
body: <p>I am trying to receive an array from useState when I click the first time on submit ,the usestate return an empty array and  this make a probleme ?</p>
  <pre><code>const [order,setOrder] = useState([]);
  
  const submit = (e) =&gt; {
  
   var NU =document.querySelector('#orderDesignation').value;
    var d =document.querySelector('#orderPrix').value;
     var p = document.querySelector('#origin').value;
  
       var q =document.querySelector('#orderQuntite').value;
      var t =document.querySelector('#orderPrixHT').value;
  
  
  const  s = { orderDesignation: &quot;d&quot; ,orderPrix: &quot;p&quot; ,orderQuntite: &quot;q&quot; ,orderPrixHT:&quot;t&quot; }
  
  console.log(&quot;s --&gt;&quot;,s);
  
  //s --&gt; Object { orderDesignation: &quot;dss&quot;, orderPrix: &quot;1&quot;, orderQuntite: &quot;3&quot;, orderPrixHT: 2 }
  
  setOrder(order =&gt; [...order,s] );
   
  console.log(&quot;order =&quot;,order);   //    order = Array[]   empty !!!! ?
  
  }
        
  </code></pre>