UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Is it legal to use a NavigationStack inside a NavigationStack?

Forums > SwiftUI

So, as per the title, I have experimented and been able to use the above situation.

I can manage a NavigationStack with its own path nested within another NavigationStack, with even it's own path.

Now, if I wanted to achieve a certain separation of concerns, would it be acceptable to nest them in such a fashion, where you have at least one (even multiple) NavigationStacks living within a root NavigationStack?

I do see that I could use a single root NavigationStack at the top of my view hierarchy, and keep passing a reference binding to the path variable to my child views on and on and on.. but this gets frustrating to manage after a time.

So, maybe I've misunderstood the WWDC videos or key Apple documentation - but is nesting these NavigationStacks as a child of a root stack an acceptable practice? Or, am I treading in deep waters?

2      

@aarku  

Did you come to a conclusion about this by chance?

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.