I have an issue in my app that apparently arises by using a NavigationStack within a sheet with a Form and NavigationLink in it like this:
struct ParentView: View {
@State private var showSheet = false
var body: some View {
Button("Show Sheet") {
showSheet = true
}
.sheet(isPresented: $showSheet) {
ChildView()
}
}
}
struct ChildView: View {
var body: some View {
Form {
NavigationLink("Navigate", value: "NextView")
.navigationDestination(for: String.self) { value in
Text("Destination: \(value)")
}
}
}
}
If you’d test this code on a simulator, it should work as expected, but if I test it on a real iPhone, the navigationDestination closure is repeatedly being called resulting in a hang.
What would be the best issue or workaround for this? Getting rid of the Form solves the problem, but my app’s design heavily relies on the design of Form/List, so that would introduce a lot of work and reconsidering of my app (so this isn’t my preferred solution ).
Thank you for reading this and maybe giving me some help!