Skip to content
Discussion options

You must be logged in to vote

This is sadly a SwiftUI bug, and it's even reproducible in vanilla SwiftUI. If you ever have a navigation hierarchy Screen A > Screen B > Screen C, such that Screen A has a navigation link and its body recomputes for any reason, then the navigation stack will be popped for some reason.

For your particular situation you can hyper focus the WithViewStore to be only around the part that needs the state, in particular don't wrap the NavigationLink inside it:

struct RootView: View {
  var store: StoreOf<Root>

  var body: some View {
    NavigationView {
      Form {
        WithViewStore(store, observe: { $0 }) { viewStore in
          Text(String(viewStore.intermediate.counter.count))
        }

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@alvarezGarciaMarcos
Comment options

@mbrandonw
Comment options

@alvarezGarciaMarcos
Comment options

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