When I am using Navigation link from a ForEachLoop I see "SwiftUI encountered an issue when pushing aNavigationLink. Please file a bug.
Unable to present. Please file a bug."
When I try to select a row, all the rows are being selected.
I used breakpoint in the destination view, I see multiple times init is getting called.
Example code:
struct ExampleHeaderView: View {
var sectionRows: [SectionRows]
@State var isActive = false
@State var isNavBarHidden = false
var body: some View {
ForEach(sectionRows) { sectionRow in
if let sectionType = sectionRow.sectionType {
switch sectionType {
case "Ex3":
VStack {
NavigationLink(destination: ExampleView(pathQuery: sectionRow.path ?? "", isActive: self.$isActive)
.navigationBarHidden(self.isNavBarHidden)
.onAppear {
self.isNavBarHidden = true
}.onDisappear {
self.isNavBarHidden = false
}
.navigationBarTitle("")
.navigationBarBackButtonHidden(true), isActive: $isActive) {
ExampleRowView(sectionRow: sectionRow)
}
.padding([.trailing, .leading], 16.0)
Divider()
}
default:
EmptyView()
}
}
}
}
}