Merge pull request #235 from SDWebImage/fix_nil_url_fixed_point

Fix the nil url always returns Error will cause infinity `onAppear` call and image manager to load, which waste CPU
This commit is contained in:
DreamPiggy 2022-09-23 17:04:13 +08:00 committed by GitHub
commit 53ac75c52b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -264,9 +264,9 @@ public struct WebImage : View {
} else {
result = AnyView(configure(image: .empty))
}
// UUID to avoid SwiftUI engine cache the status, and does not call `onAppear` when placeholder not changed (See `ContentView.swift/ContentView2` case)
// Because we load the image url in `onAppear`, it should be called to sync with state changes :)
return result.id(UUID())
// Custom ID to avoid SwiftUI engine cache the status, and does not call `onAppear` when placeholder not changed (See `ContentView.swift/ContentView2` case)
// Because we load the image url in placeholder's `onAppear`, it should be called to sync with state changes :)
return result.id(imageModel.url)
}
}