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

后端 未结 1 399
离开以前
离开以前 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:

    
        
    
    
    
    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

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