title: how to map objects from a collection , which was actually undefined but assign using object.assign
body: <p>I am trying to show the data of my collection named &quot;order&quot;. I assign the data from &quot;cart&quot; to &quot;order&quot; by using <code>order_list.doc(user.uid).update(Object.assign({}, cart))</code></p>
  <p>but when I try to show the data, it shows an error: <code>&quot;Uncaught TypeError: Cannot read properties of undefined (reading 'map')&quot;</code></p>
  <pre><code>const ConfirmOrder = () =&gt; {
    if (user) {
      order_list.doc(user.uid).update(Object.assign({}, cart))
        .then((docRef) =&gt; {
          alert(&quot;Order confirm.&quot;)
        }).catch((error) =&gt; {
          console.error(&quot;error:&quot;, error);
        });
    }
  };
  
  useEffect(() =&gt; {
    const unsubrestro = order_list.doc(user.uid).onSnapshot((snapshot) =&gt; {
      const data = snapshot.docs.map(doc =&gt; ({
        ...doc.data(),
        id: doc.id,
      }));
      setorder(data);
    });
    return unsubrestro;
  }, []);
  
  {order?.map(item=&gt; ())}
  </code></pre>