【问题标题】:Invariant Violation: requireNativeComponent: "FastImageView" was not found in the UIManager in react native不变违规:requireNativeComponent:在反应原生的 UIManager 中找不到“FastImageView”
【发布时间】:2020-03-13 11:27:09
【问题描述】:

当我写这个代码错误时,请告诉我,我穿在哪里?

从'react'导入反应,{组件}; 进口 { 样式表, 文本, 看法, 可触摸不透明度, 平面列表, 模态, } 来自 'react-native';

import FastImage from 'react-native-fast-image'

const Imagegallery = () => (
    <FastImage
        style={{ width: 200, height: 200 }}
        source={{
            uri: 'https://unsplash.it/400/400?image=1',
            priority: FastImage.priority.normal,
        }}
        resizeMode={FastImage.resizeMode.contain}
    />
)

export default Imagegallery

【问题讨论】:

    标签: reactjs react-native react-native-android native photo-gallery


    【解决方案1】:

    安装react-native-fast-image 后,你必须在你的 ios 目录中运行 pod 命令。

    所以运行这个命令:

    cd ios
    吊舱安装

    然后运行你的项目。

    【讨论】:

    • 我在 windows 中使用 expo
    • fast-image 不支持 expo。您必须为此找到替代解决方案。
    【解决方案2】:

    已经很晚了,但是对于那些遇到此错误的人,我认为最好使用 RN 60.0,因为他们没有为 RN

    如果您使用的是 RN > 60.0,只需将其粘贴到您的终端

    yarn add react-native-fast-image
    

    然后重建应用程序

    react-native run-android
    

    它现在应该可以工作了。

    【讨论】:

      【解决方案3】:

      你可以试试

      • 删除node_modules
      • 运行npm install

      添加这些行并手动链接库

      Settings.gradle

      include ':react-native-fast-image'
      project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
      

      MainApplication.java

      import com.dylanvann.fastimage.FastImageViewPackage;
      

      Podfile

      pod 'RNFastImage', :path => '../node_modules/react-native-fast-image'
      

      【讨论】:

        【解决方案4】:

        我正在使用 react-native 0.59.9,它可以在带有 react-native-fast-image 7.0.0 的 android 上正常运行。

        在 iOS 上你需要 react-native-fast-image 6.1.1,为了防止问题中描述的错误,我不得不手动安装(https://github.com/DylanVann/react-native-fast-image/blob/4fa62bb09f65d967977f25ef87eda5f8b7c18cd6/docs/installation-manual.md#ios

        【讨论】:

          猜你喜欢
          • 2020-05-06
          • 1970-01-01
          • 2019-08-27
          • 2020-09-02
          • 2021-06-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多