按照示例传递 React Native 的初始属性不起作用。
问题是 的值isSimulator
被评估为undefined
。
代码:
BOOL isSimulator = NO;
#if TARGET_IPHONE_SIMULATOR
isSimulator = YES;
#endif
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"ReactProject"
initialProperties:@{@"isSimulator": @(isSimulator)}
launchOptions:launchOptions];
反应:
var isSimulator = this.props.isSimulator;