Preload local images
See original GitHub issueIs there anyway to preload local images that are required()
?
I’m using the react-native-navigation
module for screen management and when the view loads the image is not visible, then after the animation completes, it renders the image.
I have the following render()
function:
render() {
let styles = {
position: 'absolute',
top: 0,
left: 0,
flex: 1,
width: Dimensions.get('screen').width,
height: Dimensions.get('screen').height,
};
return (
<ScrollView>
<FastImage
source={require('./assets/images/background.png')}
style={styles.bgImage}
resizeMode={'cover'} />
</ScrollView>
);
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to preload local images? - javascript - Stack Overflow
The best option would be if you preload them in componentDidMount or useEffect hook. import avatar from 'assets/avatar.png' import plants ...
Read more >Preloading responsive images - web.dev
Learn about new and exciting possibilities for preloading responsive images to ensure great user experience.
Read more >Preloading local images used via require() fails #395 - GitHub
Sometimes with even local images take a short while to load, particularly if there are many images composing full ui i.e. games.
Read more >3 Ways to Preload Images with CSS, JavaScript, or Ajax
Three easy ways to preload images using either CSS, JavaScript, or Ajax - an excellent way to speed things up and boost site...
Read more >Preloading Images | kirupa.com
What you need to do is load any images that will be used dynamically into your browser's cache. This is known as preloading....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@koodiohto: If it helps, I figured out a way to cache local images. I run the following command when my app is setting up:
List of images to preload:
Image processor:
Usage:
I am going to add support for local images. Probably soon / in the next major version. For now it does fallback to
Image
though.