Remove screen from stack navigator

后端 未结 2 725
野性不改
野性不改 2021-01-02 07:56

I’ve observed Back button logic works seeing the sequence of screens in the stack. I’ve a Drawer navigator placed inside stack navigator.

On top of the stack I’ve S

2条回答
  •  忘掉有多难
    2021-01-02 08:05

    One solution would be to reset the stack inside the splash screen component and redirect the user to the screen that you prefer:

    import { NavigationActions } from 'react-navigation'
    
    const resetAction = NavigationActions.reset({
      index: 0,
      actions: [
        NavigationActions.navigate({ routeName: 'Drawer'})
      ]
    })
    this.props.navigation.dispatch(resetAction)
    

    For newer versions of react-navigation :

    import { StackActions, NavigationActions } from 'react-navigation';
    
    const resetAction = StackActions.reset({
      index: 0,
      actions: [NavigationActions.navigate({ routeName: 'Profile' })],
    });
    this.props.navigation.dispatch(resetAction);
    

    Link to the official documentation

提交回复
热议问题