Load and return an image from Firebase database/storage in React Native

后端 未结 1 423
离开以前
离开以前 2021-01-23 02:44

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

相关标签:
1条回答
  • 2021-01-23 03:35

    I think the problem is in async invoking of getImage(), try this:

    <View style={styles.imgWrap}>
        <Image
            style={styles.candidateImg}
            source={this.state.img}/>
    </View>
    
    
    getImage(path) {
        FirebaseApp.storage().refFromURL(path).getDownloadURL().then((url) => {
            this.setState({img: {uri: url}});
        })
    }
    
    // and invoke in renderRow
    this.getImage(responseItem.imgPath)
    

    Of course you should create an array of uri's to handle <ListView />

    0 讨论(0)
提交回复
热议问题