Sometimes duplicates of a view may be re-rendered, for me, this was where a ForEach loop redrew and SwiftUI didn’t know how to distinguish between updated and non-updated views so it redrew ALL of them (in my case… many MapKit MapViews).
To solve this, make the view conform to Equatable
, implement the func ==(lhs, rhs)
function, and call .equatable()
function on the view in the parent view. This is mostly for more complex child views.
Solution was from a StackOverflow response that I thought I would share with you, but can’t find again. I’ll update this post when I have a link.
Leave a Reply