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?



Did you come to a conclusion about this by chance?


Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.