BLACK FRIDAY SALE: Save big on all my Swift books and bundles! >>

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?

   

Hacking with Swift is sponsored by RevenueCat

SPONSORED In-app subscriptions are a pain to implement, hard to test, and full of edge cases. RevenueCat makes it straightforward and reliable so you can get back to building your app. Oh, and it's free if your app makes less than $10k/mo.

Learn more

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

Reply to this topic…

You need to create an account or log in to reply.

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.