SwiftUI Refreshing Mechanism

SwiftUI's Refreshing mechanism is driving me crazy.

Say that I have this view:

NavigationView {
    List($datasource) { $item in
        NavigationLink {
           SubView(item: $item)
        } label: {
            Text(item.someAttribute)
        }
    }
}

SubView:

TextField("Placeholder", text: $item.someAttribute)

And each time I edit the value in the SubView, the SwiftUI's navigation controller retreats the view to the home page(the initial view). Why?

Answered by makabaka1880 in 725543022

Thanks I'm submitting a FB

Please file a feedback report. This seems to be a problem seen by a lot of people, and is due to the way SwiftUI handles the Binding in the List.

Accepted Answer

Thanks I'm submitting a FB

I found out why

My datasource generates a new UUID for the place of id

So everytime the view fetches the object it's a new one

SwiftUI Refreshing Mechanism
 
 
Q