我无法用我的 stackNavigator 解决错误:(0 , _nativeStack.createStackNavigator) is not a function Evaluating App.js Loading App.js

I cannot solve the error with my stackNavigator: (0 , _nativeStack.createStackNavigator) is not a function Evaluating App.js Loading App.js

我有一个 React Native 项目,当我 运行 使用 expo 时收到以下错误:

(0 , _nativeStack.createStackNavigator) is not a function
  Evaluating App.js
  Loading App.js

我不确定这是依赖性问题还是我的 createStackNavigator 的其他问题,但我似乎无法消除此错误。我已尝试清除缓存和所有内容。

  1. App.js
       import React from 'react';
   
       import { ThemeProvider } from 'styled-components';
       import { registerRootComponent } from 'expo';
       import { View, Text, Button } from 'react-native';
   
       import { createStackNavigator, createAppContainer } from '@react- 
       navigation/native-stack';
       import { createStore, applyMiddleware, combineReducers } from 'redux';
       import { Provider } from 'react-redux';
       import thunkMiddleware from 'redux-thunk';
       import reducer from './store/reducers';
   
       // Components/screens imported here
      
       const Navigator = createStackNavigator({
       
       Home: { screen: Home },
       RoutineDashboard: { screen: RoutineDashboard },
       Landing: { screen: Landing },
       Profile: { screen: Profile },
       AddAProfile: { screen: AddAProfile },
       AddProfiles: { screen: AddProfiles },
       ProfileInfo: { screen: ProfileInfo },
       Profiles: { screen: Profiles },
       EntryScreen: { screen: EntryScreen },
      
       RoutineDashboard: { screen: RoutineDashboard },
      
   
   });
   
   const App_1 = createAppContainer(Navigator);
   
   export default class App extends React.Component {
       render() {
   
           return (
               <Provider store={store}>
                   <App_1 />
               </Provider>
           )
       }
   }
  1. 这是我的 package.json 文件和依赖项:

     "dependencies": {
     "react-native-svg": "12.1.1",
     "styled-components": "^5.2.3",
     "@expo/vector-icons": "^12.0.0",
     "firebase/firestore": "8.2.3",
     "react-native-dotenv": "^2.5.5",
     "react-native-screens": "~3.4.0",
     "react-native-elements": "^3.4.1",
     "react-native-firebase": "^5.6.0",
     "react-navigation-stack": "^2.10.4",
     "@react-navigation/stack": "^5.14.3",
     "@react-navigation/native": "^5.9.3",
     "react-native-vector-icons": "^7.1.0",
     "@react-native-firebase/app": "^12.0.0",
     "react-circular-progressbar": "^2.0.4",
     "@react-native-firebase/auth": "^12.0.0",
     "react-native-dropdown-picker": "^4.0.9",
     "react-native-gesture-handler": "~1.10.2",
     "react-native-app-install-date": "^0.1.3",
     "@react-navigation/native-stack": "*",
     "react-native-circular-progress": "^1.3.7",
     "react-native-safe-area-context": "3.2.0",
     "@react-native-community/masked-view": "0.1.10",
     "react-native-animated-circular-progress": "^1.0.6",
     "react-navigation": "^4.4.4"
     }
    

正如对这个问题的回答:createStackNavigator is not a function

react-navigation 团队最近将选项卡和堆栈导航器提取到外部存储库。您需要这样做:

import { createStackNavigator } from "react-navigation-stack";

显然你需要先安装它:

npm i react-navigation-stack @react-native-community/masked-view