Reputation: 362
So I have a fetch() call returning a background url labeled as data in the following code. The url is a user uploaded image and makes a call to my backend for uploaded image.
await fetch(URL3)
.then(response => response.json())
.then(data => {
this.setState({
userBackground: data,
loading: false
});
});
After I made this call with a jpeg file (37 kb) it will not show any other file except the first jpeg I uploaded. I have tried png and jpeg files of varying sizes.
Is there some type of image cache on android that is being activated and not allowing another image to be downloaded????
My ImageBackground tag is as follows:
<ImageBackground
source={this.state.userBackground === null ? this.state.background : { uri: `${uri}` }}
style={{ width: '100%', height: '100%' }}
>
Upvotes: 0
Views: 1749
Reputation: 81
React native internally does the image caching, to get rid of this you can append the image url with time stamp. For instance,
let imageUrl = `${this.state.userBackground}?time=`+new Date();
<ImageBackground
source={imageUrl}
style={{ width: '100%', height: '100%' }}
>
Upvotes: 3