I'm having trouble implementing the TabView component on watchOS - wondering if anyone knows something I'm missing. It works fine on my iOS target, but on watchOS, a TabView with a List lets me tap one item, but returning to the main view and then tapping a second item won't result in the second view being loaded again. It works fine without the tabview of course.
class Item: ObservableObject, Identifiable {
let name: String
init(name: String) {
self.name = name
}
}
struct ContentView: View {
@State var contents: [Item] = [Item(name: "Test"), Item(name: "Test 2")]
var body: some View {
TabView {
List(contents) { (item: Item) in
NavigationLink(item.name) {
ItemView(item: item)
}
}
}
}
}
struct ItemView: View {
@State var item: Item
var body: some View {
VStack {
Text(item.name)
}
}
}