我的 React Native 应用程序中有以下代码:
<View>
<ToolBar
ButtonRightText={"Submit"}
onRightButtonPress = {(event) => {
const form = this.cForm.wrappedInstance.wrappedInstance;
}}
/>
<ComponentForm
ref={(connectView) => {
this.cForm = connectView
}}
/>
</View>
这是一个包含<Toolbar>在顶部和<ComponentForm>下方的屏幕。当屏幕加载时,回调 in<ComponentForm>被调用,并且connectView是我期望的对象。但是,当我单击 中的Submit按钮时<Toolbar>,它会调用它的回调,表明它this.cForm是undefined.
所以问题是this.cForm屏幕加载时确实设置了,但是当我单击时Submit,this.cForm它是未定义的。
任何人都知道我可以如何进行调试吗?