Actually, I am using react-native-element design language. When I used to implement checkbox than it behave like touchable opacity that I dont want.
<CheckBox
containerStyle={{ backgroundColor: "transparent", borderWidth: 0 }}
center
size={14}
title="vegetarian"
textStyle={{
fontSize: theme.FONT_SIZE_X_SMALL,
fontWeight: theme.FONT_WEIGHT_LIGHT
}}
checkedColor="red"
checked={this.state.checked}
onPress={() => this.setState({ checked: !this.state.checked })}
/>;
You can pass a Component
prop (which is TouchableOpacity
by default), with TouchableWithoutFeedback
for instance as value.
<CheckBox
Component={TouchableWithoutFeedback}
containerStyle={{ backgroundColor: "transparent", borderWidth: 0 }}
center
size={14}
title="vegetarian"
textStyle={{
fontSize: theme.FONT_SIZE_X_SMALL,
fontWeight: theme.FONT_WEIGHT_LIGHT
}}
checkedColor="red"
checked={this.state.checked}
onPress={() => this.setState({ checked: !this.state.checked })}
/>;
we can do it by anotherway activeOpacity={1}
as prop like below.
<CheckBox
activeOpacity={1}
containerStyle={{ backgroundColor: "transparent", borderWidth: 0 }}
center
size={14}
title="vegetarian"
textStyle={{
fontSize: theme.FONT_SIZE_X_SMALL,
fontWeight: theme.FONT_WEIGHT_LIGHT
}}
checkedColor="red"
checked={this.state.checked}
onPress={() => this.setState({ checked: !this.state.checked })}
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With