Avoiding Unnecessary Redraws
Scope state to minimize body re-evaluations.
The Cost of Over-Updating
If a tiny change forces a huge view to rebuild, scrolling stutters. The fix is to keep each redraw as small as possible.
State Lives Where It Changes
Put @State in the smallest view that owns it. Then only that little view re-evaluates when the value flips, not its big parent.
struct Counter: View {
@State private var count = 0
}All lessons in this course
- How SwiftUI Recomputes Views
- Avoiding Unnecessary Redraws
- Lazy Loading Heavy Content
- Profiling with Instruments