'SwiftUI About ZStack & NaviagtonLink

I use ZStack & NaviagtonLink in SwiftUI.

ZStack{
  List{
    NavigationLink(destination: NextView()) {
       Text("Hi")
    }
  } 
  Text("Hello")
}

This view is valid as I expected, and there are the text "Hello" on List's columns.

But even in NavigationLink ZStack is valid and in NextView there is hello.

I want to display it only this view, and I don't want to display it in NextView,

Please tell me how to fix.

Thank you.



Solution 1:[1]

Embed in navigationView otherwise navigation link cannot work

struct ContentView: View {
var body: some View {
    
    NavigationView{
        ZStack{
            List{
                NavigationLink(destination: NextView()) {
                    Text("Hi")
                }
            }
            Text("Hello")
        }
        .navigationBarHidden(true)
    }
    
}

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AdR