react-native-fast-image: ios: Local image not rendering
Using FastImage with source={{ uri: 'local_uri' }} does not work on ios. Works fine on android, or if I use some remote url instead. Tried with different styles. Setting fallback true doesn’t seem to do anything either.
Currently on "react-native-fast-image": "^5.1.2", and "react-native": "0.57.7"
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 19
- Comments: 26
I found solution. If your image like this
require('someImage.png'), you should putwidthandheightfor it with styles and it will work.Just use Image from react-native on IOS, my rendering issue with images was only on Android. Even with a release build.
I ctrl+f all instances of <Image …> and replaced with <FastImage …>.
It worked for all network-loaded images without any further modifications. However, local images loaded with
uri(and notrequire) did not render at all.Same issue here
I am passing the height/width for image container and FastImage component as well
<FastImage style={imageViewStyle} source={{ uri: 'https://assets.alliedelec.com/f_auto,q_auto,c_scale,w_100/70102769.jpg', }} resizeMode={FastImage.resizeMode.contain} onError={_imageLoadFailed} onLoadEnd={_imageLoaded} height={100} width={100} />but still not getting the image.I’ve found that this package does not work with “required/local” images. You cannot use
<FastImage src={require('myImage.png')}/>instead however, you can use your required images just using the standard image library. Since these are compiled in to the build of the application, I find there’s no loading time. Example below.If you’re downloading images from an API of some sorts, or even direct URL’s and saving them for caching purposes using something like
RNFSyou can use a local uri to display that image.I like to do something like this as it works around my application.
This allows me to simply call something like:
I hope this helps with everyones confusion about local images.