// // ContentView.swift // NavStackTest // // Created by samileltec on 1/14/25. // import SwiftUI struct ContentView: View { @State var path: [String] = [] var body: some View { NavigationStack(path: $path) { VStack { Text("Screen1") Spacer() Button(action: { path.append("2nd") }, label: { Text("go to 2nd Screen") }) } .navigationDestination(for: String.self) { s in if s == "2nd" { let _ = print("1st screen nav path(1) = \(path)") SecondScreen(path: $path) let _ = print("1st screen nav path(2) = \(path)") } } .onAppear { print("1st screen on appear") print("1st screen path = \(path)") } .onDisappear { print("1st screen on disappear") print("1st screen disa. path = \(path)") } .padding() } } } //#Preview { // ContentView("") // }