swiftui-cached-async-image
swiftui-cached-async-image copied to clipboard
how to show placeholder while the image url is replaced?
I am loading multiple images with CachedAsynImage, and the problem is when I replace the previous URL with a new one, the previous image is still shown and the component doesn't switch the view to the placeholder
I'm using this init:
CachedAsyncImage(url: , content: , placeholder:)
You can try to invalidate the CachedAsyncImage by settings its id to be the same as the url. In that way if the url is changed, it will invalidate the CachedAsyncImage and it will start loading from beginning.
CachedAsyncImage(url: URL(string: <url>)) { image in
...
} placeholder: {
...
}
.id(<url>)