How to identify which variable causes the UI refreshing?

Viewed 125

In general, variable marked as @State @ObservedObject @StateObject @FetchRequest can cause the UI refreshing. But in a big source, how to identify which variable cause the UI refreshing?

In most cases, onChange will do it, but in some cases, such as coredata, it's hard.

1 Answers

SwiftUI provides a special, debug-only method call we can use to identify what change caused a view to reload itself.

Updated for Xcode 13.0

var body: some View {
        print(Self._printChanges())
        return Text("Hello")
    }
Related