在React Native中实现React导航时出现错误

问题描述 投票:0回答:1
// In APP.js

import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

function HomeScreen() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screen</Text>
    </View>
  );
}

const Stack = createStackNavigator();

function Nave() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="Home" component={HomeScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
----------------------------------------------------------
In package.json

"main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-navigation/stack": "^5.2.14",
    "expo": "~37.0.3",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
    "react-native-gesture-handler": "~1.6.0",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.3.8",
    "react-native-safe-area-context": "0.7.3",
    "react-native-reanimated": "~1.7.0",
    "react-native-screens": "~2.2.0",
    "@react-native-community/masked-view": "0.1.6"
  },
  "devDependencies": {
    "babel-preset-expo": "~8.1.0",
    "@babel/core": "^7.8.6"
  },
  "private": true
}


enter image description here

[如果我能得到一些帮助,那不会是否认。根据文档,我已经通过npm的react-native和react-navigation进行了完全重新安装。但是,我不明白为什么我的应用无法启动并显示此错误消息。知道我在Macos catalina上使用了ios模拟器。

reactjs react-native native
1个回答
0
投票

[似乎您的@react-navigation/native中没有package.json。您是否遵循react-navigation docs中的说明?

© www.soinside.com 2019 - 2024. All rights reserved.