我正在尝试向我的 React-native expo 应用程序添加一个抽屉。但是运行后,它给了我标题中提到的错误。我觉得好像我缺少一些对等依赖项但是我在这里安装了反应导航文档中提到的任何内容:https ://reactnavigation.org/docs/getting-started#installing-dependencies-into-an-expo-managed-项目
这是错误来自哪里的代码:
import 'react-native-gesture-handler'; // must be very first import
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View, AppRegistry } from 'react-native';
// components
import LandingPage from './src/components/LandingPage';
import Home from './src/components/Home';
import MainMenu from './src/components/headers/MainMenu';
// navigation tools
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import {createDrawerNavigator} from '@react-navigation/drawer';
const Drawer = createDrawerNavigator();
const Stack = createStackNavigator();
export default function App() {
return (
// router page navigation
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name='Home'
component={Home}
options={{
headerLeft: (props) => (
<MainMenu />
),
headerTitle: (props)=> (
<Text style={{fontSize: 22, marginBottom: 10}}>Home</Text>
)
}}
/>
<Stack.Screen
name='landing'
component={LandingPage}
options={{ headerShown: null, animationTypeForReplace: 'pop' }}
/>
</Stack.Navigator>
<Drawer.Navigator>
<Drawer.Screen name="another" component={Home} />
</Drawer.Navigator>
</NavigationContainer>
);
};