Following code updates the values in the "numbers" array properly when I touch the "increment" button (I see the updated value when I go back), but the display on the leaf page (Text inside NavigationLink) does not update immediately for some reason (if I go back and navigate back to the leaf page again, it displays the updated value).
I'd appreciate if somebody could tell me why it does not update correctly.
I'd appreciate if somebody could tell me why it does not update correctly.
Code Block swift import SwiftUI struct NumberHolder: Identifiable { let id = UUID() let value:Int } struct Playground: View { @State var numbers:[NumberHolder] = [ NumberHolder(value:1), NumberHolder(value:2), NumberHolder(value:3), NumberHolder(value:4), ] var body: some View { NavigationView { List(numbers.indices) { index in let number = numbers[index] NavigationLink(destination: VStack { Text("Number \(number.value)") Button("Increment") { numbers[index] = NumberHolder(value: number.value + 1) } } ) { Text("Number \(number.value)") } } } } } struct Playground_Previews: PreviewProvider { static var previews: some View { Playground() } }