1

我有两个从 react-native-paper 使用的径向按钮。我在 onPress 函数下同时拥有按钮本身和它们旁边的文本,但是只有当我按下文本时才会执行该函数,而不是当我按下按钮时。当我按下按钮时,它突出显示并显示它已被按下,但不执行 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>

没有任何错误消息,我只是对它为什么不执行感到困惑。

4

1 回答 1

0

不幸的是,这听起来像是当前最新版本 2.16.0 的一个错误。它应该在 3.xx 中修复,因此您可以升级到3.0.0-alpha.8修复。

于 2019-10-22T00:27:07.543 回答