1 year ago
#210058
printDavid
why is the swiftUI list not lazy (compared to lazyVStack)?
are lists in SwiftUI really lazy? I am having a list of 5000 elements fetched from coreData and I want to display them in a list. I read a lot of comments (like that: https://developer.apple.com/forums/thread/651256) that Lists are lazy but for me it looks like they are not.... Loading the list takes 15 seconds.
List(element, id: \.objectID, selection: $selection) { file in
RowView(file)
}
If I use a ScrollView + LazyVStack + ForEach instead the loading takes less than a second.
ScrollView {
LazyVStack(alignment: .leading, spacing: 0) {
ForEach(element, id: \.objectID) { file in
RowView(file)
.onTapGesture {
selection = Set([file.objectID])
}
}
}
}
I would prefer taking a list to make use of the functionalities it provides. Am I doing something wrong or is list not lazy?
Thanks for help! (i am working with SwiftUI (for Mac)).
swift
list
lazy-loading
lazyvstack
0 Answers
Your Answer