【发布时间】:2022-08-08 19:42:03
【问题描述】:
我创建了抽屉导航,里面有堆栈导航,当从堆栈返回时需要打开抽屉
我的代码是这样的,我只需要在从任何堆栈屏幕返回后保持抽屉打开
const Drawer = createDrawerNavigator();
function DrawerNav({ navigation }) {
// toggleDrawer = () => {
// this.props.navigation.dispatch(DrawerActions.toggleDrawer())
// }
return (
<Drawer.Navigator initialRouteName=\"Home\"
screenOptions={{
headerShown: true,
headerStyle: {
backgroundColor: brand,
},
headerTintColor: primary,
headerTransparent: false,
headerTitle: \'\',
headerLeftContainerStyle: {
paddingLeft: 20,
},
}}>
<Drawer.Screen name=\"Home\" component={HomeScreen} options={horizontalAnimation}/>
<Drawer.Screen name=\"RootStack\" component={RootStack} />
</Drawer.Navigator>
);
}
const Stack = createStackNavigator();
const RootStack = () => {
return (
<Stack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: brand,
},
headerTintColor: primary,
headerTransparent: true,
headerTitle: \'\',
headerLeftContainerStyle: {
paddingLeft: 20,
},
}}
>
{storedCredentials ? (
<Stack.Screen name=\"Home\" component={DrawerNav} options={horizontalAnimation}/>
) : (
<>
<Stack.Screen name=\"Login\" component={Login} options={horizontalAnimation}/>
<Stack.Screen name=\"Signup\" component={Signup} options={horizontalAnimation}/>
</>
)}
</Stack.Navigator>
</NavigationContainer>
);
};
这些是安装的包
\"@react-navigation/drawer\": \"^6.1.8\",
\"@react-navigation/native\": \"^6.0.6\",
\"@react-navigation/stack\": \"^6.0.11\",
-
你找到任何解决方案了吗?
-
不,我没有找到任何解决方案@KishanBarmawala
标签: react-native navigation-drawer