本文介绍了不变违规:不变违规:requireNativeComponent:“RNCSafeAreaView";未在 UIManager 中找到."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:Invariant Violation: Invariant Violation: requireNativeComponent: "RNCSafeAreaView" was not found in the UIManager." 而我想使用堆栈导航器反应原生的android.此链接也没有帮助.这是我的 package.json 文件:

I get the Error : Invariant Violation: Invariant Violation: requireNativeComponent: "RNCSafeAreaView" was not found in the UIManager." while i want to use stack navigator In react native for android.this Link didn't help either. this is my package.json file :

{
  "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);

我该怎么办?

推荐答案

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

I had the same issue and to solve it I recreated the project and installed the following dependencies:

   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
}

希望能帮到你!

这篇关于不变违规:不变违规:requireNativeComponent:“RNCSafeAreaView";未在 UIManager 中找到."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 11:57