【发布时间】:2022-04-19 16:16:28
【问题描述】:
尽管将新图像上传到 s3 托管 url,但如果 uri 没有更改,<Image> 组件将不会更新图像。据我所知,这只是 Android 的问题,因为对于 iOS,您可以使用 cache: 'reload' 属性。
我已经求助this解决方案:
<Image
source={uri: imageUrlFromS3 + '?time=' + new Date(), cache: 'reload'}
style={width: 100, height: 100}
/>
通过向 url 添加一个无意义的查询,组件识别出 uri 已更改,然后刷新更新的图像。同样,我通过将密钥更改为新的 Date() 来尝试此操作。由于激进的重新渲染,这对于性能来说似乎很糟糕。
好像是this has been a problem for a long time。
我见过some answers that require using another package。
是否有不需要使用其他包的其他解决方案来解决这个问题?
【问题讨论】:
标签: android image react-native