dmytro-anokhin / url-image

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.
MIT License
1.1k stars 96 forks source link

URLIMAGE shows empty view in navlink destination #150

Closed Keno2903 closed 3 years ago

Keno2903 commented 3 years ago

‼️ Please fill in as much information as possible ‼️

Summary and/or background The URLIMAGE works perfectly unless it is put in a destination view of a navigation Link. If so, it only returns an empty view.

OS and what device you are using

Version of URLImage library 3.0.1

dmytro-anokhin commented 3 years ago

Hey, I'm looking into the problem. It seems that navigation view recreates URLImage object and this breaks loading logic on appearance. One workaround is to load images immediately, when navigation renders destination body. Set .environment(\.urlImageOptions, URLImageOptions(loadOptions: [ .loadImmediately ])).

Keno2903 commented 3 years ago

Your solution works perfectly, thanks a lot. Keep up the good work :)

dmytro-anokhin commented 3 years ago

Recently I was getting many similar bug reports, so I decided to change default behaviour to start loading when the view is rendered. There's also a new section in README that explains differences: Start Loading. If you're using List you may get better performance with old behaviour.