I have an editor view that's broken up into several subviews. The model is a relatively small struct, but it does have a couple properties that can be variable-length arrays.
The problem I'm having is after I add one entry to any one of these arrays, the view stops updating:
struct ChecksView: View {
@Binding var checks: [Check]
var body: some View {
HStack(alignment: .top, spacing: 0) {
Button("add prereq", action: {
self.checks.append(Check())
})
VStack {
ForEach(self.checks.indices, id: \.self) { i in
CheckView(check: self.$checks[i])
}
}
}
}
}
In this subview, the first time you tap "add prereq", it will add to the array & update the UI. But every subsquent time, nothing updates until you navigate away & return. What am I doing wrong?