title: Getting photo from array by path with firebase
body: <p>I'm trying to show images from array by they path but getting error</p>
  <p><code>App.js:44 Uncaught nc (in promise) TypeError: Cannot read properties of undefined (reading '_location')</code></p>
  <p>I know that I must do something with promises, async functions etc., but I don't understand at all. So below is code example</p>
  <pre><code>const fireBaseApp = initializeApp(firebaseConfig);
  const storage = getStorage(fireBaseApp);
  
  function App() {
    const [url, setUrl] = useState([]);
    const [item, setItem] = useState([]);
  
    const listRef = ref(storage, &quot;/&quot;);
    
    //getting all images from the bucket
    useEffect(() =&gt; {
      listAll(listRef).then((res) =&gt; {
        res.items.forEach(async (item) =&gt; {
          await setUrl((arr) =&gt; [...arr, item]);
        });
      });
    }, []);
  
    //Trying to download image from array with its' path
    useEffect(() =&gt; {
      const func = async () =&gt; {
        const download = ref(storage, url[2]._location.path_);
        await getDownloadURL(download).then((x) =&gt; {
          setItem(x);
        });
      };
      func();
    }, []);
  
    return (
      &lt;&gt;
        &lt;img src={item} /&gt;
      &lt;/&gt;
    );
  }
  </code></pre>
  <p>So can anybody explain please how to do it properly. Thank you !</p>