The good reuse design (and simplified view hierarchy, and update when needed explicitly) is to separate that link in standalone view for row, like
ForEach(database.decks) { elem in
DeckRowView(elem: elem)
}
and row
struct DeckRowView: View {
@ObservedObject var vm: ViewModel
init(elem: Deck) {
self.vm = ViewModel(deck: elem)
}
var body: some View {
NavigationLink (
destination: DeckDetailView(viewModel: self.vm),
label: {
ZStack(alignment: .topTrailing) {
DeckItem(viewModel: self.vm)
}
}
)
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…