Skip to content

Commit 53ac75c

Browse files
authored
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
2 parents 2221b4f + bf3d86b commit 53ac75c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ public struct WebImage : View {
264264
} else {
265265
result = AnyView(configure(image: .empty))
266266
}
267-
// UUID to avoid SwiftUI engine cache the status, and does not call `onAppear` when placeholder not changed (See `ContentView.swift/ContentView2` case)
268-
// Because we load the image url in `onAppear`, it should be called to sync with state changes :)
269-
return result.id(UUID())
267+
// Custom ID to avoid SwiftUI engine cache the status, and does not call `onAppear` when placeholder not changed (See `ContentView.swift/ContentView2` case)
268+
// Because we load the image url in placeholder's `onAppear`, it should be called to sync with state changes :)
269+
return result.id(imageModel.url)
270270
}
271271
}
272272

0 commit comments

Comments
 (0)