I used this code as part of a signup page but it keeps saying that the syntax of the navigation link was deprecated. How would I fix this? Example code: NavigationLink(destination: SignUpView(), isActive: $isNavigating) { Text("Don't have an account? Sign Up") .foregroundColor(.blue) } .padding(.top) } .padding() .navigationBarBackButtonHidden(true)
Navigation Link Syntax
Converting your example code to use the new APIs would look like this:
NavigationStack {
Button {
isNavigating = true
} label: {
Text("Don't have an account? Sign Up")
.foregroundColor(.blue)
}
.navigationDestination(isPresented: $isNavigating) {
SignUpView()
}
}
There is a lot more that can be done with NavigationLink and the navigationDestination modifier so I suggest you look at the documentation to see what else there is.
You can also watch the What's new in SwiftUI and The SwiftUI cookbook for navigation session videos from WWDC22 as well as read the Migrating to new navigation types article for more details.