Using NavigationPath to control the navigation stack
Separating NavigationLink from the destination simplifies creating deep links and also jumping to arbitrary destinations or pushing or popping several views at once.
With NavigationStack, you can attach multiple navigation destinations to handle different types of data. In this case, your destination should be expressed with NavigationPath, rather than an array of data of a specific type.
The following example does exactly that, using two instances of .navigationDestination: one to handle a destination view to handle an Int parameter, and the other to handle a String one. Notice that @State var presentedValues is initialized to NavigationPath(), and that value is bound to the initializer’s NavigationStack(path:) parameter.
Technically, NavigationPath is a type-erased list of data representing the content of a navigation stack, meaning that it can contain elements of different types.
NavigationPath as a type-erased...
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                