Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- componentDidMount () {
- const imagePaths = [
- '/static/images/illustrations/astronaut.png',
- '/static/images/wheel/contributions-communautes-techniques.png',
- '/static/images/wheel/offre.png',
- '/static/images/wheel/recrutement.png',
- '/static/images/wheel/vie-interne.png'
- ]
- var promises = []
- imagePaths.forEach(function (imagePath) {
- const promise = new Promise(function(resolve, reject) {
- let image = new Image();
- image.src = imagePath;// ici le chargement de l'image commence
- image.addEventListener('load', resolve)
- image.addEventListener('error', reject)
- });
- promises.push(promise)
- })
- Promise.all(promises).then((values) => {
- setTimeout(() => {
- this.setState({
- loaded: true
- })
- }, 1000)
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement