在反应本地人,如果希望孩子拨打父母的功能,我可以做到以下几点:阵营原生如何父函数传递给孩子
在父:
<Child myFunc={this.handleChildFunc.bind(this)} />
而孩子会这样称呼该功能:
onpress=this.props.myFunc();
如何通过passProps在Navigator和NavigatorIOS中实现此目的?
<NavigatorIOS
initialRoute={{
component: MyScene,
title: 'My Initial Scene',
passProps: { myProp: this.handleChildFunc.bind(this) } // Not work
passProps: { myProp:()=>this.handleChildFunc.bind(this) } //Not work
}}
style={{flex: 1}}
/>
更新
感谢您的回复,但我是新来的反应本地人,没有真正理解如何实现以下答案navigatorIOS。不过,我尝试以下和孩子可以成功调用父的功能
在母公司,通过回调道具
passProps: { parentFunc:()=>this.handleFunc() }
在孩子
this.props.handleFunc();
谢谢您的回答。 – bns