简体   繁体   中英

React Native Image displays different src url

In react native, the <Image> tag isn't displaying properly and shows an image from a different src URL in the database. I checked the URL multiple times, and it isn't the one displayed in the HTML.

<Image source={{uri: image}} style={styles.image} />

What is causing this glitch?

Your browser caches your url and assumes you are hitting the same url so it populates previous result. Add a random query to the url like:

https://source.com/a/b/c/image.png?randomQuery={random_number_here}

Example:

https://i.pinimg.com/564x/62/ed/6e/62ed6ea71018a57a3ab0c8c959d78cb0.jpg?key=1656566265232

React native:

 <Image
   source={{ uri: `${imageUrl}?key=${Date.now()}` }}
 />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM