I have the following code in my React Native app:
<View>
<ToolBar
ButtonRightText={"Submit"}
onRightButtonPress = {(event) => {
const form = this.cForm.wrappedInstance.wrappedInstance;
}}
/>
<ComponentForm
ref={(connectView) => {
this.cForm = connectView
}}
/>
</View>
This is a screen that contains <Toolbar>
at the top, and <ComponentForm>
below it. When the screen loads, the callback in <ComponentForm>
is called, and connectView
is an object like I expect. However, when I click the Submit
button in <Toolbar>
, it calls its callback which indicates that this.cForm
is undefined
.
So the problem is that this.cForm
does get set when the screen loads, but then when I click Submit
, this.cForm
is undefined.
Anyone know how I can approach debugging this?