【问题标题】:Expo Cli - Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManagerExpo Cli - 不变违规:requireNativeComponent:在 UIManager 中找不到“RNCSafeAreaProvider”
【发布时间】:2020-06-30 10:52:43
【问题描述】:

我在世博会客户端遇到了这个问题。该项目正在开发 iOS 模拟器和 Android 模拟器。但是当我在实际设备上使用 expo 应用程序时会出现问题。

我跑了expo start,它给了我一个二维码来扫描,我是从我的设备上扫描的。哪个显示了这个错误。

如果我只用没有react-navigation 的主组件替换抽屉导航器,它就可以工作。当我在App.tsx 中返回<Navigator /> 时,问题就出现了。

import React from 'react';
import Navigator from './navigations';
import {YellowBox, View, Text, SafeAreaView} from 'react-native';
import {useFonts} from '@use-expo/font';

YellowBox.ignoreWarnings(['VirtualizedLists should never ']);

const App = () => {
  let [fontsLoaded] = useFonts({
    Poppins: require('./assets/fonts/Poppins-Regular.ttf'),
    'Poppins-Bold': require('./assets/fonts/Poppins-Bold.ttf'),
    'Poppins-Light': require('./assets/fonts/Poppins-Light.ttf'),
  });

  if (fontsLoaded) {
    return (
      <>
        <Navigator />
      </>
    );
  } else {
    return (
      <SafeAreaView>
        <View>
          <Text>Loading</Text>
        </View>
      </SafeAreaView>
    );
  }
};

export default App;

这是 package.json

  "dependencies": {
    "@expo/vector-icons": "^10.2.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/drawer": "^5.8.2",
    "@react-navigation/material-bottom-tabs": "^5.2.10",
    "@react-navigation/native": "^5.5.1",
    "@react-navigation/stack": "^5.5.1",
    "@types/react-native-snap-carousel": "^3.8.1",
    "@use-expo/font": "^2.0.0",
    "babel-plugin-module-resolver": "^4.0.0",
    "expo": "~37.0.3",
    "expo-font": "^8.1.1",
    "expo-updates": "~0.2.0",
    "intl": "^1.2.5",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "~0.61.5",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-paper": "^3.10.1",
    "react-native-reanimated": "^1.9.0",
    "react-native-safe-area-context": "^3.0.3",
    "react-native-screens": "^2.8.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-unimodules": "~0.9.0",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "@types/react": "~16.9.23",
    "@types/react-native": "~0.61.23",
    "babel-preset-expo": "~8.1.0",
    "jest-expo": "~37.0.0",
    "typescript": "~3.8.3"
  },

【问题讨论】:

    标签: android ios react-native expo


    【解决方案1】:

    在第 2 行你导入

    import Navigator from 'navigations';
    

    在您的 package.json 中没有称为导航的包。您的想法是从 React-Navigation 导入 Navigation。我建议你阅读 React-Navigation 的入门页面:

    https://reactnavigation.org/docs/getting-started

    【讨论】:

    • 哦!这是从navigation 文件夹导入的。我已经使用 eslint config 来获得 ./navigation 的乘车体验,我将更新文件以避免混淆。但正如我提到的,它正在模拟器上工作。问题出现在 expo cli
    猜你喜欢
    • 1970-01-01
    • 2020-05-06
    • 2019-08-27
    • 2020-09-02
    • 2021-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多