From 4f734b9fd22551cd801ee3e464eee3148a32bc22 Mon Sep 17 00:00:00 2001 From: Vladimir Bajceta Date: Tue, 26 Sep 2017 14:01:05 +0200 Subject: [PATCH] preload images from nextProps in componentWillReceiveProps --- ImageCacheProvider.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ImageCacheProvider.js b/ImageCacheProvider.js index 09b284e..084cada 100644 --- a/ImageCacheProvider.js +++ b/ImageCacheProvider.js @@ -55,7 +55,7 @@ class ImageCacheProvider extends React.Component { } componentWillMount() { - this.preloadImages(); + this.preloadImages(this.props.urlsToPreload); } componentWillReceiveProps(nextProps) { @@ -63,7 +63,7 @@ class ImageCacheProvider extends React.Component { this.imageCacheManager = null; // preload new images if needed if (this.props.urlsToPreload !== nextProps.urlsToPreload) { - this.preloadImages(); + this.preloadImages(nextProps.urlsToPreload); } } @@ -79,9 +79,9 @@ class ImageCacheProvider extends React.Component { return this.imageCacheManager; } - preloadImages() { + preloadImages(urlsToPreload) { const imageCacheManager = this.getImageCacheManager(); - ImageCachePreloader.preloadImages(this.props.urlsToPreload, imageCacheManager, this.props.numberOfConcurrentPreloads) + ImageCachePreloader.preloadImages(urlsToPreload, imageCacheManager, this.props.numberOfConcurrentPreloads) .then(() => this.props.onPreloadComplete()); }