Closed pnewell closed 10 months ago
In case it is helpful, I ran the same test using the old ObservableObject and it also works fine in iOS but fails in Android.
struct Item: Identifiable {
var name: String
var id: String { name }
}
class Repository: ObservableObject {
@Published var items: [Item] = []
func set() {
self.items = [Item(name: Date().description)]
}
}
public struct ContentView: View {
@StateObject var repo: Repository = Repository()
public var body: some View {
VStack {
List {
ForEach(repo.items) { item in
Text(item.name)
}
}
Button(action: { repo.set() }) {
Text("Replace Item")
}
}
}
}
Fixed in skip-ui 0.3.36. Thanks, and please let us know if you see any issues with the update.
This example properly updates the view every time the Replace Item button is clicked in iOS but does not update the view in Android. If you swap the array for a struct
var item: Item
it works fine, so I believe this has to do with the var being an array.