I'm trying to make navigation link, here I'm creating NavigationLink with isActive based on State variable isLoggedIn. But without setting isLoggedIn true getting navigating to next screen.
- also, it's navigating on tap of
Email Textfieldwhich is wrong.
My expectation is it should navigate only after isLoggedIn setting to true.
struct ContentView: View { @State private var isLoggedIn = false @State private var email = "" var body: some View { NavigationView { NavigationLink(destination: Text("Second View"), isActive: $isLoggedIn) { VStack { TextField("Email", text: $email) .frame(maxWidth: .infinity, alignment: .leading) .border(.gray, width: 1) .foregroundColor(.blue) Button("Send") { isLoggedIn = true } } .padding() } } } }