React Native:尝试将 Stack Navigation 传递到 Bottom tab Navigation

React Native: trying to Pass Stack Navigation into Bottom tab Navigation

我在尝试将 Stack Navigator 传递到 Bottom Tab Navigator 时遇到问题。我不断收到以下错误。我哪里错了?

我创建了 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>    

}

你的代码有两个问题。
第一个代码需要修复:
[底部标签导航器]

 ...
    const Tab = createMaterialBottomTabNavigator();
    
    export const BottomNavigator = () => {
     return (
         <>                                 
                                            |
                                            |
                                            |
                                            *
  ---->   <Tab.Navigator initialRouteName="Left" activeColor="white" >
 replace it to: "Left Screen" as your tab screen name
              
     <Tab.Screen name="Left Screen" component={LeftNavigator} />
    
           //here im trying to pass in my stack navigator component to my bottom tab navigator 
              
     </Tab.Navigator>   
         </>
     )
    }

第二个:
堆栈导航器

    ....
    const LeftStack = createNativeStackNavigator();
    
    export const LeftNavigator = () => {

     //---> Add return     
return <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>    
}