SwiftUI NavigationLink not updating state on back navigation in iOS 17
Hey everyone, I'm running into an issue that's driving me crazy... Quick question that's been bugging me - I'm stuck on something that should probably be simple... I'm facing an issue with SwiftUI's `NavigationLink` where the state of my view is not updating correctly when I navigate back after modifying some data. I have a view that displays a list of items, and upon tapping one of these items, I'm pushed to a detail view. In the detail view, I'm allowing users to edit some properties of the item. After saving changes, when I navigate back, I expect to see the updated data in the list view, but it still shows the old state. Hereβs a simplified version of my implementation: ```swift struct ItemListView: View { @State private var items: [Item] = [] var body: some View { NavigationView { List(items) { item in NavigationLink(destination: ItemDetailView(item: item, onSave: { updatedItem in // Update the item in the list if let index = items.firstIndex(where: { $0.id == updatedItem.id }) { items[index] = updatedItem } })) { Text(item.name) } } .onAppear { loadData() } } } private func loadData() { // Load items from the database or API } } struct ItemDetailView: View { @State private var item: Item var onSave: (Item) -> Void var body: some View { Form { TextField("Name", text: $item.name) Button("Save") { onSave(item) // Navigate back } } } } ``` The `onSave` closure is supposed to update the list in `ItemListView`, but the issue is that when I go back to the `ItemListView`, the `items` array does not seem to reflect the changes made in `ItemDetailView`. Iβve tried using `@Binding` instead of passing the item directly to see if it would help, but the problem remains. I also checked for any potential state management issues, and ensured that Iβm using the latest iOS 17 features. What could be causing the state not to update as expected? Any suggestions on how to resolve this would be greatly appreciated! For context: I'm using Swift on Ubuntu. For context: I'm using Swift on macOS. Any ideas what could be causing this? I'm open to any suggestions.