title: how to retrieve firebase data in react-native
body: <p>im trying to fetch data from firebase database, which im getting the data very well, but when i try to push all items received in an array, i obtain an array which i cannot iterate through like any other javascript array. here is my code:</p>
  <pre><code>var li = [];
    
    useEffect(() =&gt; {
      firebaseDB
        .database()
        .ref(&quot;collection&quot;)
        .on(&quot;value&quot;, (data) =&gt; {
          let all = data;
          
          all.forEach((element) =&gt; {
            
            li.push(element.val());
          });
        });
    }, []);
    console.log(li);
  </code></pre>
  <p>when i do <code>console.log(li)</code> , i get the <code>li</code> array which seems okay with the data, but when i try to do something with the array e.g. if i do <code>console.log(li.length)</code> , it prints <code>0</code> yet the array has multiple items in it. the problem is that my <code>li</code> array doesnt behave like an array. please assist me locate where the problem could be</p>