React Navigation: Navigate Back To Root using NavigationActions.reset, goBack and getStateForAction

前端 未结 7 700
灰色年华
灰色年华 2020-12-28 15:05

Say I\'ve navigated through 4 screens in my StackNavigator App and now I want to go back to the first screen. There seems to be three different ways to do this and they do n

7条回答
  •  借酒劲吻你
    2020-12-28 15:54

    Here's a quick fix. This will remove ALL transitions when navigating (forward or backward).

    const Nav = StackNavigator({
      Screens
    },{
      transitionConfig,
      navigationOptions
    });
    

    in transitionConfig add this:

    const transitionConfig = () => ({
        transitionSpec: {
          duration: 0,
          timing: Animated.timing,
          easing: Easing.step0,
        },
      })
    

    The transitionConfig is a function that returns an object that overrides default screen transitions. https://reactnavigation.org/docs/navigators/stack

    • if someone knows a way to change animations on single navigation, I'd love to hear how!

提交回复
热议问题