我正在使用最新的反应导航(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。