我正在尝试在我的 React-native 应用程序中显示 Firebase 存储中的图像。我通过这个函数获取下载网址async:
async function getImage() {
const url = await storage()
.ref('garnele.jpg')
.getDownloadURL()
console.log(url)
return url
}Run Code Online (Sandbox Code Playgroud)
我的问题是如何将 URL 传递给 Image 组件。我试过:
<Image
source={{uri: getImage() }}
/>Run Code Online (Sandbox Code Playgroud)
但它只返回对象。
我也发现了getImage().then(result => console.log(result))- 但我不知道如何在我的情况下使用它。
javascript async-await firebase react-native firebase-storage