SwiftUI List implementation guide with OnDelete in iOS 17
I'm attempting to set up I'm experiencing an scenario where my SwiftUI List does not update properly when I use the `onDelete` modifier in iOS 17... I have a model that holds an array of items, and I am trying to allow users to swipe to delete an item from the list. However, after deleting an item, the list still shows the old items until I completely navigate away and back to the view. Here's the relevant snippet of my code: ```swift struct ContentView: View { @State private var items: [String] = ["Item 1", "Item 2", "Item 3"] var body: some View { List { ForEach(items, id: \.self) { item in Text(item) } .onDelete(perform: deleteItems) } } private func deleteItems(at offsets: IndexSet) { items.remove(atOffsets: offsets) } } ``` Despite this seemingly correct implementation, after I delete an item, the UI does not reflect the change immediately. I also tried adding `.id(UUID())` to the List but that didn't resolve the scenario. When I print the items array in the `deleteItems` function, it shows the correct update, but the UI is lagging behind. I've already checked that there are no issues with my data binding or state management. I've even tried wrapping my List in a `VStack` and using `@ObservedObject` with a model class, but the question continues. Has anyone else encountered this scenario with List updates in SwiftUI on iOS 17? Any suggestions on how to force the view to refresh? I'm open to any workarounds or best practices to handle this properly. Has anyone else encountered this? This issue appeared after updating to Swift LTS.