Javascript 事件按外部视图反应本机

Javascript 事件按外部视图反应本机,javascript,react-native,mobile,Javascript,React Native,Mobile,我想在按下外部按钮时关闭选择器?请帮忙 1.第一种解决方案 <View > <TouchOpacity opPress={closePopup}> <View>{Popup of u here}</View> </TouchOpacity> </View> {u在此弹出} 使用react本机元素库的覆盖 不看代码是什么很难回答,但您可以尝试以下方法: closePopup = _ =&g

我想在按下外部按钮时关闭选择器?请帮忙

1.第一种解决方案

<View >
    <TouchOpacity opPress={closePopup}>
        <View>{Popup of u here}</View>
    </TouchOpacity>
</View>

{u在此弹出}
  • 使用react本机元素库的覆盖

  • 不看代码是什么很难回答,但您可以尝试以下方法:

    closePopup = _ => {
      this.setState(previousState => ({ isFlatListVisible: false }));
    }
    
    <TouchableWithoutFeedback onPress={this.closePopup}>
      {isFlatListVisible && <FlatList />}
    </TouchableWithoutFeedback>
    
    closePopup=\u=>{
    this.setState(previousState=>({isFlatListVisible:false}));
    }
    {isFlatListVisible&&}
    
    您正在使用哪个库我不使用库,我使用平面列表来渲染项目。向我们显示代码谢谢,但我想在按下“外部”时关闭选择器,您知道查看事件吗?