【发布时间】:2017-07-06 08:13:54
【问题描述】:
我有一个 SectionList,其中包含许多从 firebase 存储中获取的图像。向下滚动时,它会迅速生成大量警告。
WebImage 组件如下所示:
import React, { Component } from 'react'
import { View, Image } from 'react-native'
import firebase from 'firebase'
class WebImage extends Component {
state = {
imgsrc: '',
mounted: false,
}
componentDidMount() {
this.setState({ mounted: true })
firebase
.storage()
.ref()
.child(this.props.source)
.getDownloadURL()
.then(url => {
if (this.state.mounted) {
this.setState({ imgsrc: url })
}
})
}
componentWillUnmount() {
this.setState({ mounted: false })
}
render() {
...
}
}
export default WebImage
如你所见,我试图让它知道安装状态,但它没有按预期工作..
【问题讨论】:
标签: reactjs firebase asynchronous react-native firebase-storage