Hello colleagues,
I have question regarding passing data that doesn't need to change. In video suggested to use let
, and it totally make sense! But I also found following issue:
https://forums.raywenderlich.com/t/question-regarding-chapter-8-4/136398/2
I am wondering how to avoid rendering path optimisation to make sure it's not cached somewhere in between? Or was this something already fixed in prior SwiftUI versions?
My example:
struct ModelDetailsView {
@ObservedObject var viewModel: ViewModel
@ViewBuilder
var body: some View {
ModelItemsSection(viewModel.$model.subitems)
.onAppear(perform: {
self.viewModel.load()
})
}
}
struct ModelItemsSection: View {
let items: [ModelSubitem] // simple struct
var body: some View {
PreviewItemsView(items: items,
allItemsTitle: "All Items") { item in
Text(item.titleDetail + item.subtitle)
} allItemsView: { items in
//3rd level screen where `let` data is passed that's destination to NavigationLink
AllModelItemsView(items: items)
}
}
}
Thanks, Dzmitry.