NavigationLink initializer unused

Hello everybody,

I am trying to navigate from one view to another using NavigationView and NavigationLink.

I can't figure out what I am doing wrong, but the way I am doing it I get a warning saying:

"Result of NavigationLink<Label, Destination> is unused".

In fact, I can't navigate to the view I want to open.

Here is my code so far:

Code Block
NavigationView {
VStack {
Button(action: {
let observation = self.createObservation()
self.records.addObservation(observation)
self.isPresented.toggle()
NavigationLink(destination: ObservationDetails(observation: observation).environmentObject(self.records)) {
EmptyView()
}
}) {
  Text("Classify")
}
}


Thank you for your help!
You cannot put a view declaration (including NavigationLink) inside an action closure.

Why don't you simply use NavigationLink instead of Button?

Result of 'NavigationLink<Label, Destination>' initializer is unused I am facing same issue

@fashraf did you solve this issue? I'm also facing the same issue now

@fashraf did you solve this issue? I'm also facing the same issue now. If you resolved this, can you help me how did you achieve this situation? Thanks in advance.