如何在React Navigation v.3中传递初始路线道具?在v.2中,我用于导出默认的抽屉,例如
export default ({ initialRouteName }) => {
return createBottomTabNavigator(
{
AnimeStack,
TvStack,
FilmStack
},
{
initialRouteName: initialRouteName
}
);
};
表示如果我通过初始路径传递了一个对象,它将首先渲染该屏幕。我试图在v.3这样的版本中实现
const DrawerNavigation = ({ initialRouteName }) => {
return createDrawerNavigator(
{
AnimeStack,
TvStack,
FilmStack,
},
{
initialRouteName: initialRouteName ,
}
);
};
const MainTabNaigator = createAppContainer(DrawerNavigation);
export default MainTabNaigator;
但是没有用。任何帮助表示赞赏。
答案 0 :(得分:1)
要导出默认的“ DrawerNavigator”,应该是这样。
const AnimeStack = createStackNavigator (
{
Home: AnimationController,
}, {
intialRouteName: "Home",
})
const RootStack = createDrawerNavigator({
Animations: AnimeStack,
TVs: TvStack,
Films: FilmStack,
}, {
intialRouteName: 'Animations',
});
export default createAppContainer(RootStack);