Navigation Link SwiftUI MVVM


I have a toolbar with a button that should take me to a new view via NavigationLink like so:

.toolbar {
            ToolbarItem(placement: .confirmationAction) {
                let vm = viewModel.add()
                NavigationLink("", destination: Add(viewModel: vm))
                    .buttonStyle(AddButtonStyle())
            }
         }

with the viewModel add function simply returning a viewModel for the Add view. I have this similar functionality elsewhere in my code and it works perfectly, but here the view never spawns. I did some debugging and the init for the AddViewModel is being executed repeatedly. But I can’t figure out why the Add View is never spawning, and I am stuck on the previous screen.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img