8.2 · The update loop, dependency tracking and the cost of body

SwiftUI redraws by re-evaluating body for the views whose inputs changed, not the whole screen. Understanding what invalidates a view is the whole performance story.

Mental model. A view is re-evaluated when something it read changes. Slow screens are almost always views that read too much, or body doing too much.

The update loop

What triggers <code>body</code> and what makes it expensive.

  1. How does SwiftUI decide to re-run body, and how do you keep updates cheap? 8.2.1 · L5
    SwiftUI maintains a graph of attributes behind your views. When a view’s body reads a piece of state (a @State value, a binding, an environment value, or, with…

More in SwiftUI