state based navigation #1398
-
Hi! I'm having some trouble trying to do state based navigation. I have three views of which one is reused in this example:
ViewB navigates to C using the following: struct ViewB: View {
var body: some View {
WithViewStore(store) { viewStore in
ViewBInternals {
// view layout
}.background(
NavigationLink(
destination: ViewC(store: store.scope(
state: \.cState,
action: B.Action.cAction
)),
isActive: viewStore.binding(\.$showCView)
)
)
}
}
} ViewA navigates to both B and C using: struct ViewA: View {
var body: some View {
WithViewStore(store) { viewStore in
ViewAInternals {
// view layout
}.background(
NavigationLink(
destination: ViewB(store: store.scope(
state: \.bState,
action: A.Action.bAction
)),
isActive: viewStore.binding(\.$showBView)
)
)
.background(
NavigationLink(
destination: ViewC(store: store.scope(
state: \.cState,
action: A.Action.cAction
)),
isActive: viewStore.binding(\.$showCView)
)
)
}
}
} Now whenever I navigate from A to B and then try to navigate to C. C shows up shortly and then B is rerendered and shown instead of C. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Is it possible to provide some code that shows the problem that we can run locally? It seems a little weird that B shows up at all if you are navigating to C. That could only happen if |
Beta Was this translation helpful? Give feedback.
Is it possible to provide some code that shows the problem that we can run locally? It seems a little weird that B shows up at all if you are navigating to C. That could only happen if
showBView
is true at some point.