我在尝试将我的堆栈导航器传递到我的底部标签导航器时遇到了麻烦。我一直得到下面的错误。我哪里出错了?
我创建了Stack导航组件,然后将其导入到底部选项卡导航中,然后将组件传递到那里。
底部标签导航器
import * as React from 'react';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
import { LeftNavigator } from '../stack.navigation.js/stack';
const Tab = createMaterialBottomTabNavigator();
export const BottomNavigator = () => {
return (
<>
<Tab.Navigator initialRouteName="Left" activeColor="white" >
<Tab.Screen name="Left Screen" component={LeftNavigator} />
//here im trying to pass in my stack navigator component to my bottom tab navigator
</Tab.Navigator>
</>
)
}
堆栈导航器
import * as React from 'react';
import { CnnScreen } from '../news.screens.js/cnn';
import { Reuters } from '../news.screens.js/reuters';
import { TheVerge } from '../news.screens.js/the.verge'
import { StyleSheet, Text, SafeAreaView, ScrollView, View, Image, TouchableOpacity} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { LeftScreen } from '../left/left.screen';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
const LeftStack = createNativeStackNavigator();
export const LeftNavigator = () => {
<LeftStack.Navigator initialRouteName='Left'>
<LeftStack.Screen name="Left" component={LeftScreen}/>
<LeftStack.Screen name="CNN" component={CnnScreen}/>
<LeftStack.Screen name="Reuters" component={Reuters}/>
<LeftStack.Screen name="TheVerge" component={TheVerge}/>
</LeftStack.Navigator>
}
2条答案
按热度按时间bqujaahr1#
您代码中有两个问题。
需要修复的第一个代码:
[底部选项卡导航器]
第二:
堆栈导航器
abithluo2#
=〉此处orderNavigator是您的堆栈导航器,即const OrderNavigator =()=〉{ return(<Stack.Navigator initialRouteName="order">〈堆栈屏幕名称={'order'}组件={试用版}选项={{headerShown:错误}}/〉</Stack.Navigator>); };