【发布时间】:2015-10-27 05:18:15
【问题描述】:
在我的场景中,当专注于 TextInput 时,我正在使用导航器(使用推送)移动到另一个场景,在那里我填充列表,在该列表中选择一个值,该值应该填充到 TextInput 的前一个场景在这种情况下,我是无法将所选值设置为 TextInput 的上一个场景。
我的代码结构是
var FirstComponent = React.createClass({
render:function(){
return(<TextInput value="" placeholder="Enter value" onFocus={getData.bind(this)} />)
}
})
function getData(ev){
var target = ev;
this.props.navigator.push({
id:'SecondComponent',
name:'SecondComponent',
target:target,
})
}
var SecondComponent = React.createClass({
render:function(){
return(<TouchableHighlight onPress={fillData.bind(this,target, self.props.navigator,selectedText)}><Text>sample</Text></TouchableHighlight>)
}
});
function fillData(rootThis,nav,selectedText,ev){
rootThis.value=selectedText;
rootThis.nativeEvent.target = selectedText;
rootThis.nativeEvent.target .text= selectedText; // Here ' rootThis ' is route object 'this'
//how to fill selectedText in FirstComponent TextInput value
}
【问题讨论】:
标签: react-native