I have a hybrid react-native app and I have some static images which are loaded from the bundle. In the app when I open a page containing the images, it shows a gray rectangle while the image is getting decoded. Here are some pics of what I mean:
When the page loads, I can see the left image first and after a delay of ~0.2 seconds the right image fades in. I have searched for this issue and I can't find any clean workarounds. This is the code I use to load the image:
<Image
style={{
height: 30,
width: 30,
marginStart: 5,
}}
source={require('../assets/google-logo.png')}
/>
I have even tried to load the images through application bundles (i.e. add the image through XCode/Android Studio) but again the same happens. I thought this might be an effect of the debug version as it is loading from the packager but then I built a release version and the same happened.
I have seen some solutions which use the state of the component to set a flag when the Image is loaded and then render the component but I think there should be something better. Are there any clean solutions to this problem?
This is very disappointing about react-native that it cannot load simple small images in a pleasant way!