使用 React Navigation 6,在文档中,他们建议您使用组来最小化嵌套导航器。
但是,我不确定如何在本示例中执行此操作,在选项卡导航器中使用嵌套堆栈:
import * as React from 'react';
import { View, Button } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
function FeedScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button
title="Go to Settings"
onPress={() => navigation.navigate('Settings')}
/>
</View>
);
}
function ProfileScreen() {
return <View />;
}
function SettingsScreen() {
return <View />;
}
const …Run Code Online (Sandbox Code Playgroud)