Hey all,
I have a complex View that sometimes it's getting re-created for some events that I do not understand. I put the _PrintChanges() in the View body, and here's what I got:
EditPageComponentControlHostView: @self, @identity, _pageController, _componentController, _hasContent changed.
struct EditPageComponentControlHostView: View {
@Environment(EditPageController.self) var pageController
@State private var componentController = EditPageComponentController()
@State private var hasContent = false
It seems like the View is being reset since the @State hasContent
has been reset. It seems like if the View's @identity has changed, SwiftUI will re-create the view hence the variable _hasChanged has been reset.
So I tried:
- conform EditPageComponentControlHostView to Equatable, and @identity is still changing.
- Set id on EditPageComponentControlHostView like this:
EditPageComponentControlHostView()
.id("Test")
and it still changing the identity. What did I miss? Thanks!