为什么 redux store 的 object 属性 值来自 firestore '9' 而不是 img url?
Why is redux store's object property value from firestore '9' instead of img url?
当屏幕在我的 react-native 应用程序中加载时,我使用来自 redux 存储的 url,由 firestore 读取操作填充(图像存储在 firebase-storage 中)作为源图像组件。如果我像 source={{ui:this.props.someURL}}
这样创建图像的源道具,我会得到
TypeError: NSNull cannot be converted to NSString
好的,我知道这是关于图像源道具的已知问题。我尝试用以下方法修复它:
source={{
uri: this.props.profileImg == null ?
require('../assets/img/white-user.png') :
this.props.profileImg
}}
然后我从问题标题中得到错误:
JSON value '9' of type NSNumber cannot be converted to NSString
如果我完全删除有问题的图像组件,没有错误。
构造函数中 this.props.someURL
的记录值 = null
componentDidMount()
中 this.props.someURL
的记录值 = null
正如预期的那样,因为这些值是由承诺填充的。那么为什么会出现 JSON value of '9'
错误呢?这仅在 iOS
您可以替换您的源道具
来自
source={{
uri: this.props.profileImg == null ?
require('../assets/img/white-user.png') :
this.props.profileImg
}}
到
source={
this.props.profileImg == null ?
require('../assets/img/white-user.png') : {
uri:this.props.profileImg
}
}
当屏幕在我的 react-native 应用程序中加载时,我使用来自 redux 存储的 url,由 firestore 读取操作填充(图像存储在 firebase-storage 中)作为源图像组件。如果我像 source={{ui:this.props.someURL}}
这样创建图像的源道具,我会得到
TypeError: NSNull cannot be converted to NSString
好的,我知道这是关于图像源道具的已知问题。我尝试用以下方法修复它:
source={{
uri: this.props.profileImg == null ?
require('../assets/img/white-user.png') :
this.props.profileImg
}}
然后我从问题标题中得到错误:
JSON value '9' of type NSNumber cannot be converted to NSString
如果我完全删除有问题的图像组件,没有错误。
构造函数中 this.props.someURL
的记录值 = null
componentDidMount()
中 this.props.someURL
的记录值 = null
正如预期的那样,因为这些值是由承诺填充的。那么为什么会出现 JSON value of '9'
错误呢?这仅在 iOS
您可以替换您的源道具
来自
source={{
uri: this.props.profileImg == null ?
require('../assets/img/white-user.png') :
this.props.profileImg
}}
到
source={
this.props.profileImg == null ?
require('../assets/img/white-user.png') : {
uri:this.props.profileImg
}
}