[ad_1]
The beneath checklist view masses 1000 rows and I see 1000 NameTextView
being created.
However with reusability we must be seeing only a few NameTextView
. Is there a option to optimize the code and variety of rows that will likely be created.
I’m doing related factor as posted in Reply for query Reusability assist in Checklist in SwiftUI
import SwiftUI
struct ListContentView: View {
var objects = createList()
var physique: some View {
Checklist(objects) { aspect in
NameTextView(identify: aspect.identify)
}
.listStyle(PlainListStyle())
}
}
struct NameTextView: View {
var identify: String
var physique: some View {
Textual content(identify)
}
}
#Preview {
ListContentView()
}
struct ListElement: Identifiable {
var id = UUID().uuidString
var identify: String
}
func createList() -> [ListElement] {
var objects: [ListElement] = []
for i in 0..<1000 {
objects.append(ListElement(identify: "Identify (i)"))
}
return objects
}
[ad_2]