EquatableView on iOS 14 and 15

I have been noticing that on iOS 15 I get much fewer "redundant" calls to body (the framework is "smarter"...).
I can't really know what's happening in 14 because I can't use _printChanges() (is there a way via a breakpoint on body or some other way to see what changed on iOS 14?), but I tried to enforce avoiding re-render via Equality and seems like the system ignores my equality on iOS 14, and still keeps calling body for a view that returns true from ==. The eq function does get called, I also checked and _isPOD() is false for my view.

What is the difference in iOS 14 that entails still calling body even when == is called and returns true? And is there any way around this?

struct SomeView: View {
  @State someState = true
  var body: some Body {
    ChildView(someFlag: someState).equatable()
  }
}

struct ChildView: View, Equatable {
  static func == (lhs: ChildView, rhs: ChildView) -> Bool {
    lhs.someFlag == rhs.someFlag // <- returns true
  }
  let someFlag: Bool
  @State something = Something() // <- not POD
  var body: some View { ... } // <- called on iOS14, not on 15...
}
1 Like
Terms of Service

Privacy Policy

Cookie Policy