在 React Native 中的 MaterialTopTabNavigator 上动态切换 swipeEnabled [英] Dynamically toggle swipeEnabled on MaterialTopTabNavigator in React Native

查看:57
本文介绍了在 React Native 中的 MaterialTopTabNavigator 上动态切换 swipeEnabled的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 React Native Navigation 中的 Material Top Tab Navigator,它是通过 createMaterialTopTabNavigator() 创建的.根据文档,这个函数接受一个 TabNavigatorConfig 对象作为第二个参数,它有一个属性 swipeEnabled 决定你是否应该能够在不同的选项卡之间滑动.

I'm using the Material Top Tab Navigator from React Native Navigation, created with createMaterialTopTabNavigator(). As per the documentation, this function accepts a TabNavigatorConfig object as the second argument, which has a property swipeEnabled determining if you should be able to swipe between the different tabs.

问题是,我通常希望启用滑动行为,但只想在某些情况下禁用它.一旦在其中一个选项卡中触发了某个事件,有没有办法在 truefalse 之间动态切换?

The issue is, I normally want the swipe behavior enabled, but only want to disable it under certain circumstances. Is there a way to toggle this between true and false dynamically once a certain event is triggered in one of the tabs?

推荐答案

您需要使用 React Navigation 5(目前为 alpha)进行动态配置:

You need to use React Navigation 5 (currently alpha) for dynamic configuration:

https://next.reactnavigation.org/

这篇关于在 React Native 中的 MaterialTopTabNavigator 上动态切换 swipeEnabled的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆