【发布时间】:2015-11-05 07:02:16
【问题描述】:
使用 react-native navigator 时 我正在使用这样的 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
// I am trying to move the response data to props because I am using this data in my saveRecord function but it isn't showing up there.
}
}
render: function(){
<View>
<TouchableHighlight style={styles.touchButtonBorder} underlayColor="#ffa456" onPress={saveRecord.bind(this,this.props)}>
<Text style={styles.button}>SAVE</Text>
</TouchableHighlight>
</View>
}
})
为什么不给道具分配数据?
【问题讨论】:
-
props是只读的。 -
但是在 reactjs 中它可以工作。但是为什么 ti 不适用于 react native