Prevent Parent touchable opacity onPress if child touchable opacity is disabled

640 Views Asked by At

I have a component like this:

<TouchableOpacity onPress={parentOnPress}>
  <TouchableOpacity onPress={childOnPress} disabled={isDisabled}>
    <View><Text> Just a child </Text></View>
  </TouchableOpacity>
</TouchableOpacity>

if isDisabled is true, and the child TouchableOpacity is clicked, then it triggers the parentOnPress method.

How to prevent this from happening?

0

There are 0 best solutions below