title: Array isn't filled with object in Javascript
body: <p>So after the content is loaded in the website I'm trying to call a function to fill [fields] (State) with the events but something Isn't working.</p>
  <p>Here is what I mean:</p>
  <pre class="lang-js prettyprint-override"><code>const [events, setEvents] = useState([]);
  
  useEffect(() =&gt; {
      if (orders.orders !== null &amp;&amp; orders.isLoading !== true)
        orders.orders.map((order) =&gt;
          setEvents([
            ...events,
            {
              title: `Meeting with ${order.customer.firstName}`,
              date: `${order.appointment}`,
            },
          ])
        );
      setLoading(false);
    }, [orders]);
  
  </code></pre>
  <p>So when I console log the events, I get <code>[]</code> (empty), but if i console.log the object it works.</p>