List item identity
In a SwiftUI List showing live prices, every price update makes rows flicker and reappear and the scroll position jumps. How should you define the model's Identifiable id?
In a SwiftUI List showing live prices, every price update makes rows flicker and reappear and the scroll position jumps. How should you define the model's Identifiable id?
Make the id a domain key that doesn't change when the price does, like a ticker symbol or market code (for example BTC-KRW), and keep the price, update time, and a UUID() created on every decode out of it, so List sees a value change on the same row and updates it in place.
SwiftUIShort answerIntro
How is the way SwiftUI draws the screen fundamentally different from UIKit?
#swiftui
SwiftUIShort answerBasics
UIView is a class, so why was SwiftUI's View designed as a struct?
#identity
SwiftUIShort answerBasics
SwiftUI views have no viewDidLoad or viewWillAppear like UIKit. How does a view actually…
#identity
SwiftUIShort answerAdvanced
In the code below, toggling isCompact wipes whatever was typed in the text field. Can you…
#identity