【发布时间】:2015-11-05 04:44:46
【问题描述】:
在我的场景中,我使用导航器渲染组件。在该组件中,我执行了一些操作,例如保存记录,然后我向现有组件动态添加了一个新道具。但是这里的动态道具在该组件中不可见,只有以前的道具才可见。如何使用navigator实现给组件添加动态prop。
这里我在使用 React Native 导航器时提供代码我正在调用 DisplayCustomSchema 组件,如下所示
this.props.navigator.push({
id: 'DisplayCustomSchema',
name: 'DisplayCustomSchema',
org:this.props.org
});
在 DisplayCustomSchema 组件 componentDidMount 中,我调用了一个 ajax 发布它返回一些数据。
var DisplayCustomSchema = React.createClass({
componentDidMount : function(){
ajaxpost(data){//example only
this.props.record=data
//here i am try to move response data to props because I am using this data in saveRecord function but in save record props contain name and org only
}
}
render: function(){
<View>
<TouchableHighlight style={styles.touchButtonBorder} underlayColor="#ffa456" onPress={saveRecord.bind(this,this.props)}>
<Text style={styles.button}>SAVE</Text>
</TouchableHighlight>
</View>
}
})
我的问题是为什么数据不移动到道具
【问题讨论】:
标签: javascript jquery reactjs react-native