在expo下使用react-native-fast-image组件 import FastImage from 'react-native-fast-image' const Imagegallery 下运行会报错:requireNativeComponent: "FastImageView" was not found in the UIManager in react native 报错的原因是react-native-fast-image
缓存图片: 使用第三方库 (如 react-native-fast-image) 缓存图片。3.JS 引擎优化减少 JS 执行时间: 避免复杂的计算放在 JS 线程中。
npm install react-native-fast-imageimport React from 'react';import FastImage from 'react-native-fast-image 按需加载图片:使用 react-native-fast-image 等库,它支持图片的按需加载和缓存,只有当图片进入可视区域时才进行加载。2.
图片加载用 react-native-fast-image,页面初始化的逻辑使用 InteractionManager.runAfterInteractions。去掉无用的 View 层。
解决方法: 1、使用Image自带的getSize方法先获取宽高 2、使用别的大神的组件React Native Fit Image 等 资源超过400kb左右不显示 所以说原生组件, 推荐使用别的组件库:react-native-fast-image
可以通过使用第三方库react-native-fast-image来解决上面的这些问题。
2、优先使用 32 位色彩深度的图片 色彩深度 wiki:https://github.com/DylanVann/react-native-fast-image/blob/master/README.md 4、使用 react-native-fast-image react-native-fast-image 文档:https://github.com/DylanVann/react-native-fast-image /blob/master/README.md 经过上面的几个 Image 属性分析,综合来看,Image 组件对图片的管理能力还是比较弱的,社区上有个 Image 组件的替代品:react-native-fast-image
在这种情况下使用的第三方库: iOS: 加载和缓存图像 — Nuke Android: 加载和缓存图像 — Glide React Native: 加载和缓存图像— React-native-fast-image
在 ListView 中,有1000个元素,并且到达列表最后一个元素的滚动时间相同,这里使用到了一些第三方库: ios Nuke Android Glide react native React-native-fast-image
FlatList, View, Text, Image, Dimensions, Platform, } from'react-native'; import FastImage from'react-native-fast-image
这里推荐使用react-native-fast-image,其iOS端基于SDWebImage,Android使用Glide来加载图片,有比较完善的缓存机制,能够快速加载并显示图片。