我收到错误消息:Invariant Violation:Invariant Violation:requireNativeComponent:“在UIManager中找不到“ RNCSafeAreaView”。”而我想使用堆栈导航器对Android进行本机响应。
this Link也没有帮助。这是我的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-native-community/masked-view": "^0.1.6",
    "expo": "35.0.0",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "0.59.8",
    "react-native-gesture-handler": "^1.3.0",
    "react-native-reanimated": "^1.2.0",
    "react-native-safe-area-context": "^0.3.6",
    "react-native-screens": "^1.0.0-alpha.23",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^2.0.15"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0",
    "babel-preset-expo": "~8.0.0",
    "jetifier": "^1.6.5"
  },
  "private": true
}



这是我的导航组件:

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

import Home from "../screens/Home";
import ReviewDetails from "../screens/ReviewDetails";

const screens = {
  home: {
    screen: Home
  },
  reviewDetails: {
    screen: ReviewDetails
  }
};

const homeStack = createStackNavigator(screens);

export default createAppContainer(homeStack);



我该怎么办?

最佳答案

我遇到了同样的问题,为了解决这个问题,我重新创建了项目并安装了以下依赖项:

   expo install react-navigation
   expo install react-navigation-stack
   expo install react-native-gesture-handler
   expo install react-native-safe-area-context
   expo install @react-native-community/masked-view


这是我的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": {
    "expo": "~36.0.0",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^2.0.16",
    "react-native-gesture-handler": "~1.5.0",
    "react-native-safe-area-context": "0.6.0",
    "@react-native-community/masked-view": "0.1.5"
  },
  "devDependencies": {
    "babel-preset-expo": "~8.0.0",
    "@babel/core": "^7.0.0"
  },
  "private": true
}


希望对您有所帮助!

关于javascript - 永久违反:永久违反:requireNativeComponent:在UIManager中找不到“RNCSafeAreaView”。,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59824985/

10-10 18:04