简体   繁体   中英

React Navigation:How to disable tab navigator swipe when in a stack navigator

React Navigation on Android: When in a stack navigator, how to disable swipe of tab navigator. thx

ABCNav.navigationOptions = ({ navigation, screenProps }) => {
    if (navigation.state.index != 0) {
        return {
            tabBarVisible: false,
            swipeEnabled: false, //disable swipe inside StackNavigator
        };
    }
    return {
        tabBarVisible: true, 
//enable swipe function for first screen
    };
};

Add this to each screen in the StackNavigator:

static navigationOptions = {
  swipeEnabled: false,
}

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