I have a SwiftUI List pushed through NavigationLink. But when I scroll down the data suddenly turn empty. Not sure why? Xcode 14.2 Here's my implementation
- Parent View (doesn't has issue)
NavigationView {
List {
ForEach(viewModel.endorsements, id: \.name) { endorsement in
EndorsementListItem(endorsement: endorsement)
.background {
NavigationLink {
viewModel.buildEndorsmentListDetail(endorsement)
} label: {
EmptyView()
}.opacity(0)
}
.padding(.vertical, 16)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
}
}
.padding(.horizontal, 12)
.listStyle(.plain)
...
- Child View (which has the issue)
struct EndorsementListDetail: View {
var body: some View {
List {
ForEach(viewModel.endorsement.details) { detail in
VStack(spacing: 8) {
EndorsementListDetailItem(detail: detail)
Divider()
}
.listRowSeparator(.hidden)
.listRowInsets(EdgeInsets(top: 8, leading: 12, bottom: 0, trailing: 12))
}
}
.listStyle(.plain)
...
}
When I scroll down, the list turn empty
Anyone have any idea why this is happening?