Navigate to root screen from nested stack navigator

后端 未结 4 1140
迷失自我
迷失自我 2021-01-18 21:59

i am new to react and trying to learn it by myself , i am facing problem in navigating user back to root screen from nested stck navigator screen .

Here is some of m

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-18 22:03

    As per react navigation doc you can go to any stack by following ways: check the following link for more details React-navigation stack action link

    1. import { StackActions, NavigationActions } from 'react-navigation';
             const resetAction = StackActions.reset({
              index: 0,
              actions: [NavigationActions.navigate({ routeName: 'Profile' })],
            });
            this.props.navigation.dispatch(resetAction);
    
    1. If you have a stack for profile then you can also go through like this check following link nested react navigation

    import { NavigationActions } from 'react-navigation';
    
    const navigateAction = NavigationActions.navigate({
      routeName: 'Profile',
    
      params: {},
    
      action: NavigationActions.navigate({ routeName: 'SubProfileRoute' }),
    });
    
    this.props.navigation.dispatch(navigateAction);

提交回复
热议问题