简体   繁体   中英

event Press outside view react native

I want to close picker when I press outside? Please help

在此处输入图片说明

1.First solution

<View >
    <TouchOpacity opPress={closePopup}>
        <View>{Popup of u here}</View>
    </TouchOpacity>
</View>
  1. Using Overlay of react-native-elements libary

It is difficult to answer without looking at what your code is but you could try something like this:

closePopup = _ => {
  this.setState(previousState => ({ isFlatListVisible: false }));
}

<TouchableWithoutFeedback onPress={this.closePopup}>
  {isFlatListVisible && <FlatList />}
</TouchableWithoutFeedback>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM