Skip to content

Commit

Permalink
preload images from nextProps in componentWillReceiveProps
Browse files Browse the repository at this point in the history
  • Loading branch information
bajceta committed Sep 26, 2017
1 parent 3d005ab commit 4f734b9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ImageCacheProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ class ImageCacheProvider extends React.Component {
}

componentWillMount() {
this.preloadImages();
this.preloadImages(this.props.urlsToPreload);
}

componentWillReceiveProps(nextProps) {
// reset imageCacheManager in case any option changed
this.imageCacheManager = null;
// preload new images if needed
if (this.props.urlsToPreload !== nextProps.urlsToPreload) {
this.preloadImages();
this.preloadImages(nextProps.urlsToPreload);
}
}

Expand All @@ -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());
}

Expand Down

0 comments on commit 4f734b9

Please sign in to comment.