I've got a Firebase app setup, with an array of items in the Realtime Database. Each item has an imagePath
node, containing a Firebase Storage URI (eg. gs://bucket/images/stars.jpg).
The array of items is used in a <ListView/>
, and I need to load an image in each row.
Seen as the images aren't stored directly in a "plain" URL format, I need to use the storage API to get that.
So in my renderRow(responseItem)
function, I've got the following:
<View style={styles.imgWrap}>
{this.getImage(responseItem.imgPath)}
</View>
And that function is the following:
getImage(path) {
FirebaseApp.storage().refFromURL(path).getDownloadURL().then((url) => {
return (
<Image
style={styles.candidateImg}
source={{uri: url}}/>
)
})
}
The problem is, nothing's being returned.
If I run a console.log(url)
above the return
in getImage
, it logs the correct URL, that I can open in browser.
Tldr; storage API is getting image URL correctly, but react-native isn't returning the <Image/>
component.