I have two radial buttons I'm using from react-native-paper. I have both the buttons themselves and the text next to them under an onPress function, however only when I press on the text does the function execute, not when I press on the button. When I press on the button, it highlights and shows that it was pressed, but doesn't execute the onPress.
<View style={[s.profile_gender_row]}>
<Text onPress={() => {this.onDataChange('gender', 'F')}}>Female</Text> // this works just fine
<RadioButton
value="F"
status={this.props.gender === 'F' ? 'checked' : 'unchecked'}
onPress={() => {this.onDataChange('gender', 'F')}} // this does not work
/>
</View>
<View style={[s.profile_gender_row]}>
<Text onPress={() => {this.onDataChange('gender', 'M')}}>Male</Text>
<RadioButton
value="M"
status={this.props.gender === 'M' ? 'checked' : 'unchecked'}
onPress={() => {this.onDataChange('gender', 'M')}}
/>
</View>
There aren't any error messages, I'm just stumped at why it's not executing.
{}
. Just call the onPress as this:{() => this.onDataChange('gender', 'M')}
and it should work – darkknightonPress={() => this.onDataChange('gender', 'M')}
– David