ForEachStore + NavigationLink + IfLetStore #1786
Answered
by
idelfonsog2
idelfonsog2
asked this question in
Q&A
-
I'm going 😵💫🫠 I'm expecting whenever I tapped a cell to navigate to the detailView, I'm building the Reduce { state, action in
switch action {
case .cell(id: let id, action: _):
state.optionalState = OptionalState()
}
}
.forEach(\.cells, action: /Action.cell(id:action:)) {
Cell()
}
.ifLet(\.optionalState, action: /Action.detail) {
DetailReducer()
} SwiftUIView: // ...
Section("section name") {
ForEachStore(self.store.scope(state: \.items, action: Main.Action.cell(id:action:))) { cellStore in
NavigationLink(isActive: viewStore.binding(get: \.isNavigationActive, send: Main.Action.setNavigation(isActive:))) {
IfLetStore(self.store.scope(state: \.itemState, action: Main.Action.itemsFiltered),
then: { FilteredView(store: $0) },
else: { EmptyView() })
} label: { CellView(store: cellStore) }
}
}
//... Not sure if I'm missing a |
Beta Was this translation helpful? Give feedback.
Answered by
idelfonsog2
Jan 4, 2023
Replies: 1 comment
-
Found my issue 😵💫 I was not sending any action into my ChildReducer hence the parent was not building my optional state from the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
idelfonsog2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found my issue 😵💫 I was not sending any action into my ChildReducer hence the parent was not building my optional state from the
Parent.Action.cell(id: let id, action: _)