【发布时间】:2018-07-17 13:58:51
【问题描述】:
我正在将初始属性传递给我的 React Native 应用程序。
NSDictionary *dictionary = @{@"testID": @"123"};
这是在 React Native 端收到的,并显示
{"rootTag":1,"initialProps":{"testID":"123"}}.
但是,我正在读取 React Native 端的数据 -
componentWillMount() {
var token = this.props.testID;
console.log("testID is " + token);
}
它给出错误 JSON 值 NSNull 无法转换为 NSString。
testID 未定义
【问题讨论】:
-
代码 sn-p
@{"testID": @"123"}正确吗?在"testID"文字之前应该有一个@符号。
标签: objective-c react-native react-native-ios