Skip to content

Navigation Stack Pops When Parent View Content Loads #57

Discussion options

You must be logged in to vote

Hmmm, that is strange behaviour, thanks for sharing @fishcharlie. I'm not too sure but think what is happening in FirstView is something like:

  • Each branch of the conditional if let items is a different view with its own identity.
  • Wrapping it in Group doesn't change that, as Group is transparent in terms of identity.
  • When items changes from nil to non-nil, the identity of FirstView changes.
  • FlowStacks has added a NavigationLink invisibly to the background of FirstView, which is initially active.
  • Since the NavigationLink is attached to FirstView, when FirstView's identity changes, SwiftUI sees this NavigationLink as a new NavigationLink, and understands that the previous NavigationLink has…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fishcharlie
Comment options

Answer selected by johnpatrickmorgan
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