Search code examples
react-nativereact-navigationexporeact-navigation-stack

How do I prevent react-navigation from showing a transition animation during StackAction.reset?


Using react-navigation-stack 1.10.3, resetting StackActions loads the new stack in place without a transition. The same code snippet with react-navigation-stack 2.0.15 adds a platform default transition, which for iOS is SlideFromRightIOS.

How do I replicate the previous behavior on 1.10.X with 2.0.X where there is no transition while the stack gets reset?

navigation.dispatch(
    StackActions.reset({
        index: 0,
        actions: [
            NavigationActions.navigate({
                routeName: user ? 'Home' : 'Landing',
            }),
        ],
    }),
);


Solution

  • You can disable animation for these screens by adding animationEnabled: false in the navigationOptions of your Home and Landing screens.

    Home.navigationOptions = {
      animationEnabled: false
    }