'How to view PDF doc from Firebase storage in React using react-pdf?

I would like to view a pdf file from firebase storage in my React app, the problem is I would like to view the file after the page is loaded and the 'getDownloadURL' firebase method is async.

I tried to do something like this:

    const MyPage = (props) => {
      const [numPages, setNumPages] = useState(null)
      const [pageNumber, setPageNumber] = useState(1)
      const [url, setURL] = useState('')
    
     const showFile = async () => {
        return await storage.ref(props.props.sheetMusicRef).getDownloadURL()
      }
    
    return   <Document file={showFile}>
              <Page pageNumber={pageNumber} />
            </Document>
}

with no success.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source