【发布时间】:2018-06-14 20:29:53
【问题描述】:
我有这样的代码 - 我正在将我的图像保存到正在获取和打印正确 URL 的状态
fetchData = async () => {
this.setState({profilePicUrl: await
AsyncStorage.getItem('profileImg')});
//here it is printing the right URL
console.log('this.state.profilePicUrl '+this.state.profilePicUrl);
console.log('this.props.profile '+this.props.profile);
};
但是在同一个组件的render方法中
<Thumbnail source={{uri: this.state.profilePicUrl}} style={{ height: 100, width: null, flex: 1 }} />
这个缩略图没有显示任何内容,在 EXPO XDE 中我看到 source.uri 是一个空字符串
我已经像这样在渲染方法中记录了 profilePicUrl
render() {
console.log('In Render method of Profile');
console.log('In Render method of Profile this.state.profilePicUrl
'+this.state.profilePicUrl);
并且能够在控制台中获取 url。但是,我看到了这个错误
source.uri 不应为缩略图中的空字符串
这个问题与这个问题类似,因为我也使用 Firebase 来存储和检索图像
Setting image source to Firebase Storage URL with React Native
【问题讨论】:
标签: javascript image reactjs react-native