I want to run account creation logic and then, if successful, transition to the destination view. Otherwise, I\'ll present an error sheet. NavigationLink transitions immedia
You can wrap your Destination View in a lazy view to prevent the immediate invocation. Here's an example:
struct LazyView: View {
let build: () -> Content
init(_ build: @autoclosure @escaping () -> Content) {
self.build = build
}
var body: Content {
build()
}
}
Eventually, invoke it like this:
NavigationLink(destination: LazyView(Text("Detail Screen"))){//your code}
I've written a full blog post covering this a few other pitfalls of NavigationLinks in SwiftUI. Refer here.