@applicaster/react-native-fast-image

中文文档
8.8.2发布于 2026/01/14(MIT AND Apache-2.0)TypeScriptESM + CJS零依赖近 30 天下载 5234

🚩 FastImage, performant React Native image component.

原始使用文档
文档目录29 节
  1. Features
  2. Usage
  3. Are you using Glide already using an AppGlideModule?
  4. Are you using Proguard?
  5. Properties
  6. source?: object
  7. source.uri?: string
  8. source.headers?: object
  9. source.priority?: enum
  10. source.cache?: enum
  11. defaultSource?: number
  12. resizeMode?: enum
  13. onLoadStart?: () => void
  14. onProgress?: (event) => void
  15. onLoad?: (event) => void
  16. onError?: () => void
  17. onLoadEnd?: () => void
  18. style
  19. fallback: boolean
  20. tintColor?: number | string
  21. Static Methods
  22. FastImage.preload: (source[]) => void
  23. FastImage.clearMemoryCache: () => Promise<void>
  24. FastImage.clearDiskCache: () => Promise<void>
  25. Troubleshooting
  26. Development
  27. Supported React Native Versions
  28. Credits
  29. Licenses

🚩 FastImage

Performant React Native image component.

Version Downloads Build Status Code Coverage

Watch on GitHub Star on GitHub Tweet


FastImage example app.

React Native's Image component handles image caching like browsers for the most part. If the server is returning proper cache control headers for images you'll generally get the sort of built in caching behavior you'd have in a browser. Even so many people have noticed:

  • Flickering.
  • Cache misses.
  • Low performance loading from cache.
  • Low performance in general.

FastImage is an Image replacement that solves these issues. FastImage is a wrapper around SDWebImage (iOS) and Glide (Android).

Features

  • Aggressively cache images.
  • Add authorization headers.
  • Prioritize images.
  • Preload images.
  • GIF support.
  • Border radius.

Usage

Note: You must be using React Native 0.60.0 or higher to use the most recent version of react-native-fast-image.

yarn add react-native-fast-image
cd ios && pod install
import FastImage from 'react-native-fast-image'

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

Are you using Glide already using an AppGlideModule?

Are you using Proguard?

If you use Proguard you will need to add these lines to android/app/proguard-rules.pro:

-keep public class com.dylanvann.fastimage.* {*;}
-keep public class com.dylanvann.fastimage.** {*;}
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

Properties

source?: object

Source for the remote image to load.


source.uri?: string

Remote url to load the image from. e.g. 'https://facebook.github.io/react/img/logo_og.png'.


source.headers?: object

Headers to load the image with. e.g. { Authorization: 'someAuthToken' }.


source.priority?: enum

  • FastImage.priority.low - Low Priority.
  • FastImage.priority.normal (Default) - Normal Priority.
  • FastImage.priority.high - High Priority.

source.cache?: enum

  • FastImage.cacheControl.immutable - (Default) - Only updates if url changes.
  • FastImage.cacheControl.web - Use headers and follow normal caching procedures.
  • FastImage.cacheControl.cacheOnly - Only show images from cache, do not make any network requests.

defaultSource?: number

  • An asset loaded with require(...).
  • Note that like the built-in Image implementation, on Android defaultSource does not work in debug mode. This is due to the fact that assets are sent from the dev server, but RN's functions only know how to load it from res.

resizeMode?: enum

  • FastImage.resizeMode.contain - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).
  • FastImage.resizeMode.cover (Default) - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
  • FastImage.resizeMode.stretch - Scale width and height independently, This may change the aspect ratio of the src.
  • FastImage.resizeMode.center - Do not scale the image, keep centered.

onLoadStart?: () => void

Called when the image starts to load.


onProgress?: (event) => void

Called when the image is loading.

e.g. onProgress={e => console.log(e.nativeEvent.loaded / e.nativeEvent.total)}


onLoad?: (event) => void

Called on a successful image fetch. Called with the width and height of the loaded image.

e.g. onLoad={e => console.log(e.nativeEvent.width, e.nativeEvent.height)}


onError?: () => void

Called on an image fetching error.


onLoadEnd?: () => void

Called when the image finishes loading, whether it was successful or an error.


style

A React Native style. Supports using borderRadius.


fallback: boolean

If true will fallback to using Image. In this case the image will still be styled and laid out the same way as FastImage.


tintColor?: number | string

If supplied, changes the color of all the non-transparent pixels to the given color.

Static Methods

FastImage.preload: (source[]) => void

Preload images to display later. e.g.

FastImage.preload([
    {
        uri: 'https://facebook.github.io/react/img/logo_og.png',
        headers: { Authorization: 'someAuthToken' },
    },
    {
        uri: 'https://facebook.github.io/react/img/logo_og.png',
        headers: { Authorization: 'someAuthToken' },
    },
])

FastImage.clearMemoryCache: () => Promise<void>

Clear all images from memory cache.

FastImage.clearDiskCache: () => Promise<void>

Clear all images from disk cache.

Troubleshooting

If you have any problems using this library try the steps in troubleshooting and see if they fix it.

Development

Follow these instructions to get the example app running.

Supported React Native Versions

This project only aims to support the latest version of React Native.
This simplifies the development and the testing of the project.

If you require new features or bug fixes for older versions you can fork this project.

Credits

The idea for this modules came from vovkasm's react-native-web-image package. It also uses Glide and SDWebImage, but didn't have some features I needed (priority, headers).

Thanks to @mobinni for helping with the conceptualization

Licenses

  • FastImage - MIT © DylanVann
  • SDWebImage - MIT
  • Glide - BSD, part MIT and Apache 2.0. See the LICENSE file for details.

版本与发布记录

@applicaster/react-native-fast-image 共发布 14 个版本,首次发布于 2020/05/22;过去 12 个月发布了 1 个版本。

版本发布日期距今
8.8.2latest2026/01/149 个月前
8.8.12025/02/071.7 年前
8.8.02025/02/061.7 年前
8.8.0-dev.32025/02/061.7 年前
8.8.0-dev.22025/02/051.8 年前
8.8.0-dev.12025/02/051.8 年前

关于 @applicaster/react-native-fast-image 的常见问题

@applicaster/react-native-fast-image 是什么?

🚩 FastImage, performant React Native image component.

如何安装 @applicaster/react-native-fast-image?

在项目目录运行 npm install @applicaster/react-native-fast-image,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^17 || ^18)、react-native(>=0.60.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@applicaster/react-native-fast-image 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@applicaster/react-native-fast-image 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@applicaster/react-native-fast-image 可以商用吗?

@applicaster/react-native-fast-image 使用 (MIT AND Apache-2.0) 许可。声明的许可为 (MIT AND Apache-2.0),请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@applicaster/react-native-fast-image 的下载量有多少?

根据 npm 官方下载统计,@applicaster/react-native-fast-image 在 2026/10/07 – 2026/11/05 这 30 天内被下载 5,234 次,日均约 174 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@applicaster/react-native-fast-image 还在维护吗?

最新版本 8.8.2 发布于 2026/01/14(9 个月前);至今共发布 14 个版本,其中过去 12 个月发布了 1 个;首次发布于 2020/05/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。