我正在更新用户个人资料图片,并且能够看到数据库中的图像发生变化。我将图像的位置存储在个人资料图片中。我能够看到重新加载应用程序时发生的变化,并且能够立即看到 firebase 存储中的图像发生变化。
这是结构:
这是我用来更改图像的功能:
export const changeUserAvatar = (userId, imageUrl) => {
firebaseService
.database()
.ref('users/' + userId)
.update({
profilePicture: imageUrl
});
};
这是我渲染图像的方式:
<Avatar size="xlarge" rounded source={{ uri: this.props.profilePicture }} onPress={this.openPicker}/> :
我正在使用 redux 来管理状态,并认为它会自动重新渲染并更新个人资料图片的值。我在这里尝试了一切:
https://github.com/facebook/react-native/issues/9195
https://github.com/facebook/react-native/issues/12606
当我尝试添加这样的东西时,我根本没有得到图像,它显示为一个空白屏幕:
{{uri: profilePicture + '?' + new Date()}}
当我导航回我的消息列表时,我面临同样的问题/图片仅在我对应用程序进行硬重新加载时才会改变。