对nestedNavigations中的特定路由选项卡做出本机重置反应

时间:2018-12-16 23:08:28

标签: react-native react-navigation

我正在使用最新的反应导航(3.0),并且嵌套了导航器。

    import TabStack from './TabStack'
    let MainStack = createStackNavigator({
        TabStack: TabStack,
        screenA: screenA,
        screenB: screenB

      },{
        headerMode: 'none',
        lazy:true,
        initialRouteName:'TabStack'
      });
export default createAppContainer(MainStack);

TabStack

    import { createBottomTabNavigator, createAppContainer } from 'react-navigation';

let TabStack = createBottomTabNavigator(
    {
        TabA: TabA,
        TabB: TabB,
    }
)
export default createAppContainer(TabStack);

我想从ScreenA重置为TabB,所以我想做的是

 let dispatch = StackActions.reset({
        index: 0,
        actions: [
            NavigationActions.navigate({ routeName: 'TabStack',
                action: NavigationActions.navigate({
                    routeName: 'TabB', 
                  })
            }),
        ]
    })
    this.props.navigation.dispatch(dispatch)

成功重置为TabStack而不重置为TabB,它重置为TabA。

0 个答案:

没有答案