Home > Software design >  How to avoid onPress function works inside the inner Views in React-Native
How to avoid onPress function works inside the inner Views in React-Native

Time:07-27

I want to avoid the onPress={() => onRequestClose()} function working inside the inner View in my react-native project.

While user click on the screen the (whatever the area) onPress={() => onRequestClose()} works, to avoid that I use View inside the 1st TouchableWithoutFeedback and inside the View component I added another TouchableWithoutFeedback. But this is not working.

I'm struggling to find the solution, Is there any method to resolve this matter.

My code as follows

<View style={styles.videoOverlayWrapper}>
    <TouchableWithoutFeedback onPress={() => onRequestClose()} style={{width: '100%', height: '100%'}}>
    <View><TouchableWithoutFeedback onPress={()=>{}}>{props.children}</TouchableWithoutFeedback></View>
    </TouchableWithoutFeedback>
</View>

enter image description here

CodePudding user response:

you can pass null in any onPress, as onPress={() => null} or onPress={null}

<View style={styles.videoOverlayWrapper}>
    <TouchableWithoutFeedback onPress={() => null} style={{width: '100%', height: '100%'}}>
</View>
  • Related