在带有 wix/react-native-navigation 的模态中使用 react-native-gesture-handler (RNGH)

Posted

技术标签:

【中文标题】在带有 wix/react-native-navigation 的模态中使用 react-native-gesture-handler (RNGH)【英文标题】:Using react-native-gesture-handler (RNGH) inside a modal with wix/react-native-navigation 【发布时间】:2021-01-18 22:56:41 【问题描述】:

我正在尝试在 react-native-modal 结合 wix/react-native-navigation 中使用 RNGH 组件,例如 TouchableOpacity它不起作用。当我点击它时,没有发生任何交互。

react-native 导入TouchableOpacity 似乎有效。问题是,我想使用import TouchableOpacity from 'react-native-navigation';,因为它比原来的响应更快。

谁能解释一下原因,或者解决方法?

这是我的应用结构:

Wix react-native-navigation
|
|-- gestureHandlerRootHOC( Component (The Screen) )
      |
      |----- <Modal />
      |         |
      |         |------ TouchableOpacity <-- I cannot press this
      |
      |----- TouchableOpacity <-- But I can press this

【问题讨论】:

我刚刚注意到,这种情况适用于 android,但不适用于 ios 【参考方案1】:

据我了解,react-nativeModal 组件创建了一个不受react-native-navigation 管理的本机ViewController,因此没有被gestureHandlerRootHOC 包裹。

我建议通过 Navigation.showModal(). That way your modal is also a registered screen wrapped with the gestureHandlerRootHOC` 显示 RNN 模态。

【讨论】:

我喜欢使用 Navigation.showModal(),尤其是在 Apple 设备中。 Apple 支持 Modal 场景,Android 只显示全屏页面?

以上是关于在带有 wix/react-native-navigation 的模态中使用 react-native-gesture-handler (RNGH)的主要内容,如果未能解决你的问题,请参考以下文章