Skip to content

Commit bf3d86b

Browse files
committed
Fix the nil url always returns Error will cause infinity onAppear call and image manager to load, which waste CPU
Instead, use url as identity to avoid this
1 parent 2221b4f commit bf3d86b

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)