Skip to content

How to push a NavigationStack from another root NavigationStack #3265

Answered by JanC
JanC asked this question in Q&A
Discussion options

You must be logged in to vote

I've got it working by using delegate actions and letting the root views handle the navigation. I believe that's what @mbrandonw also suggested in another thread on Slack.

Starting from the completed 02-04-navigationstacks, the steps I did to be able to reuse the ContactsView both as a root of the navigation as well as a child of an existing navigation are the following:

  • Remove the NavigationStack from the ContactsView
  • Replace the NavigationLink by regular buttons that send a view action to the ContactsFeature.Store
  • The ContactsFeature.Store sends a delegation action case didSelectContact(Contact)

This basically extracts the ContactsView from any navigation.

To embedd the ContactsView

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@JanC
Comment options

@mbrandonw
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by JanC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants