且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从React Native中的Firebase数据库/存储加载并返回图像

更新时间:2023-01-06 22:26:09

我认为问题在于异步调用 getImage(),试试这个:

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)

当然你应该创建一个uri数组来处理< ListView />

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