2
component A
render(){
<View>
{this.renderB()}
{this.renderC()}
</View>
}
component B
super(props){
this.state={text: (this.props.text) ? this.props.text : '' }
}
render(){
}
component C
super(props){
}
render(){
<View>
<TouchableHighlight onPress={
...here I want to modify text state of component B
}></TouchableHighlight>
</View>
}
是否可以像這樣修改同級的狀態?還是應該將text
屬性移到組件A?操縱同級組件的狀態