I read everywhere that List is supposed to be Lazy on iOS but following snippet seems to contradict it
import SwiftUI
struct Item {
var id: Int
}
let items = (1...30000)
.map { v in
Item(id: v)
}
struct ItemRow:View{
let item: Item
init(item: Item){
self.item = item
print("init #\(item.id)")
}
var body: some View{
Text(String(item.id))
}
}
struct ContentView: View {
var body: some View {
// ScrollView {
// LazyVStack {
// ForEach(items, id: \.id) { item in
// ItemRow(item: item)
// }
// }
// }
List(items, id: \.id) { item in
ItemRow(item: item)
}
}
}
This prints out 30000 times twice (new empty project). Also checked that ItemRow's body is also called for all 30k items immediately.
Am I missing something?
List?