In my SwiftUI project with deployment target iOS 14, I have a RootView with sub-view View1 in the below formate. How to programmatically navigate back to RootView with View1 from View3.
struct RootView: View {
var body: some View {
VStack {
if condition1 {
View1()
} else {
SomeOtherView()
}
}
}
}
struct View1: View {
var body: some View {
NavigationLink to -> View2
}
}
struct View2: View {
NavigationLink to --> View3
}