How SwiftUI Recomputes Views
Understand identity, value, and diffing.
Views Are Cheap Descriptions
A SwiftUI view is not a heavy object. It is a lightweight description of what the screen should look like right now. SwiftUI builds and discards them constantly.
body Runs Again and Again
When data changes, SwiftUI calls your view's body again to get a fresh description. This is normal and expected, not a bug.
var body: some View {
Text("Count: \(count)")
}All lessons in this course
- How SwiftUI Recomputes Views
- Avoiding Unnecessary Redraws
- Lazy Loading Heavy Content
- Profiling with Instruments