Upgrading from 9.x
FastImage 10 is a native New Architecture component. Apart from the changes below, the API is the same as in 9.x. Apps that can’t move to the New Architecture on React Native 0.83 or later can stay on FastImage 9 (npm install react-native-fast-image@9), which gets fixes from the 9.x branch.
Requirements
Section titled “Requirements”- React Native 0.83 or later, with the New Architecture (the legacy architecture isn’t supported).
- Expo SDK 55 or later.
- iOS and tvOS 15.1 or later, with SDWebImage 5.21.5 or later. If
pod installcan’t find a compatible SDWebImage (yourPodfile.lockhas an older one), update it withcd ios && pod update SDWebImage. - Android 7.0 (API 24) or later. FastImage builds with
compileSdkVersionandtargetSdkVersion36 by default, and uses Glide 5.0.7 (glideVersion4.15 or later works too): see Android build settings.
Changes
Section titled “Changes”resizeModeis removed: useobjectFit.containandcoverkeep their names,stretchisfill, andcenterisscale-down. Tiling (resizeMode="repeat") is no longer supported. AresizeModeprop or style is ignored, so the image shows withobjectFit’s default,cover.FastImage.resizeModeis still there, deprecated, so code that reads it doesn’t break.overlayColoris removed fromImageStyle. It had no effect.FastImage.priorityandFastImage.cacheControlare deprecated: pass the strings instead (priority: 'high',cache: 'immutable'). They still work, and will be removed in a later major version.- No children.
FastImageis a single native view and doesn’t render children: useFastImageBackgroundfor content over an image.FastImageBackgroundis in 9.x too, so you can switch to it before upgrading. - The ref is the native view. It has the same methods as before (
measureand so on). Jest snapshots show oneFastImageViewelement. fallbackis removed. Images always load with FastImage’s native views; use React Native’sImagefor images that need it.- On Android, images fade in by default (300 ms); iOS doesn’t change. To keep 9.x’s behavior, turn it off for every image when the app starts:
FastImage.setDefaults({ transition: false }).transition={null}now means the default, not no fade. - iOS events: a handler added after its image loaded (e.g.
onLoadgiven on a later render) isn’t called for that load. - The native module is the TurboModule
FastImageModule(NativeModules.FastImageViewis gone). This only matters to code that used it directly instead of FastImage’s functions. - Android package: FastImage’s Android classes are in
com.fastimage(wascom.dylanvann.fastimage). Apps that use autolinking need no change. If your app addsFastImageViewPackageby hand or imports FastImage’s classes, use the new name. FastImage ships its own ProGuard rules, so you can remove rules you added for it.FastImageProgressListeneris removed. - Images your app loads with Glide (a
GlideUrl, from its own native code or another library) use React Native’s OkHttp client on Android, with your app’s interceptors and cookies: see images your app loads with Glide.