不变违规:requireNativeComponent:在React Native中未在UIManager中找到“ FastImageView”

当我写此代码错误时,请让我知道我在哪里?

从'react'导入React,{组件};     导入{       StyleSheet,       文本,       视图,       TouchableOpacity,       flatList,       模态     }来自“ 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
jiguanni 回答:不变违规:requireNativeComponent:在React Native中未在UIManager中找到“ FastImageView”

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

因此,请运行以下命令:

  

cd ios
  吊舱安装

然后运行您的项目。

,

已经很晚了,但是对于那些遇到此错误的人,我认为使用RN 60.0更好,因为它具有自动链接功能,因为他们不提供RN

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

yarn add react-native-fast-image

然后重新构建应用

react-native run-android

现在应该可以了。

,

我使用的是react-native 0.59.9,它可以在Android上使用react-native-fast-image 7.0.0正常工作。

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

,

你可以试试

  • 删除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'
本文链接:https://www.f2er.com/3083342.html

大家都在问