react native 子组件向父组件传值

父组件:
 
引入子组件:import CheckBox from  '../checkbox';
 
父子之间交互通信,接受子组件的值
fn(val){
this.setState({
roleType:val
});
}
 
//调用通信
<CheckBox data={this.state.roleType} isRow={styles.isRow} fn={this.fn.bind(this)}/>
 
子组件:
其中fn里面传递的值为要传递给父组件的值
onPress={()=>{
this.props.fn(this.state.data)
}}
原文地址:https://www.cnblogs.com/yuxingxingstar/p/9852960.html