【发布时间】:2015-09-22 13:54:24
【问题描述】:
我不是 JS 或 React 程序员,但我需要在我的项目中使用它。
我想将值从我的本机代码传递给我的 React 视图,以便它由 React 引擎呈现。
我尝试了很多变化
我的原生代码如下:
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"ReactTesting"
launchOptions:@{@"initialProps" : @"<Text>Hello from native code</Text>"}];
rootView.initialProperties = @{@"initialProps" : @"<Text>Hello from native code</Text>"}; // ???
在我的反应代码中,我想渲染那个 JSX:
var ReactForTesting = React.createClass( {
render: function() {
return (The Launch Options that were sent to this view); //How do I render it?
}
});
我尝试在渲染函数中返回各种东西 - 没有一个会渲染:
render : function () {
return this.props; // doesn't work
}
render : function () {
return this.props.initialProps; // doesn't work
}
render : function () {
return this.props.initialProps; // doesn't work
}
also fiddling with:
React.createElement()
React.createClass()..
【问题讨论】:
标签: ios facebook reactjs react-native