SwiftUI - Show alert when go to new page

I  want an alert to be displayed when the user is moved to a new page without any action and quickly.
I use NavigationLink

I try for this
Code Block
@State private var showAlert = true

but there was no result
you can help me ?
Answered by miladsoftware in 675506022
I was solve with this code changes

Code Block
struct SecondView: View {
@State var showAlert = false
var body: some View {
// i want to show alert when navigate to this view
VStack{
Text("Second View")
.alert(isPresented: $showAlert) {
Alert(title: Text("You are in second view"))
}
}.onAppear{
showAlert = true
}
}
}


thanks all

Please show more code, this is not enough.
ContentView.swift
Code Block
struct ContentView: View {
var body: some View {
VStack{
NavigationLink(destination: SecondView()){
Text("Go to second view")
}
}
}
}


SecondView.swift
Code Block
struct SecondView: View {
@State var showAlert = true
var body: some View {
// i want to show alert when navigate to this view
VStack{
Text("Second View")
.alert(isPresented: $showAlert) {
Alert(title: Text("You are in second view"))
}
}
}
}

Accepted Answer
I was solve with this code changes

Code Block
struct SecondView: View {
@State var showAlert = false
var body: some View {
// i want to show alert when navigate to this view
VStack{
Text("Second View")
.alert(isPresented: $showAlert) {
Alert(title: Text("You are in second view"))
}
}.onAppear{
showAlert = true
}
}
}


thanks all

SwiftUI - Show alert when go to new page
 
 
Q