Using navigationDestination with NavigationStack
This is a feature introduced with SwiftUI 4 that is available with iOS 16. Another common use of .navigationDestination is passing an element from a list to a destination view, using a NavigationLink.
Let’s begin with a simple array inside a List.
Here is our code example:
import SwiftUI
struct EmployeeView: View {
let name: String
var body: some View {
Text("\(name)")
.font(.largeTitle)
.navigationTitle("Selected employee")
.foregroundColor(.secondary)
}
}
struct ContentView: View {
let employee = [
...