mardi 9 octobre 2018

Caching images in react js

I am writing an app in react js using firebase as the backend service. The images names and location is stored in the realtime database and is accessed and then the file(image) is fetched from the cloud storage and displayed on the screen.

eg.

getFile(path){
   firebase.database().ref('').child(path).once('value').then(snap =>{
       cloudStorage.child(snap.val()).getDownloadURL().then(url =>{
            return url;
       });
   });
}

So the fetched image url is provided as a source to an image tag

<img src={this.state.fetchedImage}/>

Can I download this and save this image to the web storage so that I download the image again when my view re-renders?

Thanks, Zeeshan




Aucun commentaire:

Enregistrer un commentaire