Created
December 2, 2017 07:53
-
-
Save biyootiful/4f41e097d5a711f3500839b592a04d1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentWillMount(){ | |
this.preloadImg(); | |
} | |
... | |
preloadImg(){ | |
const imgURLs = imageURLsFromData; | |
for(let i = 0; i<imgURLs.length; i++){ | |
let downloadingImg = new Image(); | |
downloadingImg.src = imgURLs[i]; | |
downloadingImg.onload = () =>{ | |
imgLoadCount++; | |
if(imgLoadCount === imgURLs.length){ | |
//initially set to "in progress" | |
this.setState({loading:"done"}); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment