title: Cant update my array or state using Firebase - React Native
body: <p>I'm a little stuck developing my application. So far im able to connect to the Firestore db and get my documents. My plan is to fetch the data from each document and store it in an array. From there i will display it.</p>
  <p>The issue im having is that the results from the first time render wont add the elements to the array. DATA.push() method works but its not saved outside of this forEach loop?
  Thanks!</p>
  <p><strong>const data is where the document ref is stored.</strong></p>
  <p><strong>const DATA = [] is the array.</strong></p>
  <pre><code>const [data, setdata]= useState([{}]);
  
  useEffect(() =&gt; {
    const getUsers = async () =&gt; {
      const data = await getDocs(usersCollectionRef);
      data.forEach(doc =&gt;{
  
        DATA.push({id: doc.id, title: doc.data().Type, status: doc.data().status, location: doc.data().Location, type: doc.data().Type, injured: doc.data().Injured, collar: doc.data().Collar, color: doc.data().Colour })
      
      })
      
    };
  
    getUsers();
    console.log(dataNew);
   
  }, []);
  const DATA = [];
  </code></pre>
  <p><a href="https://i.stack.imgur.com/VX4zZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VX4zZ.png" alt="Example" /></a></p>