Skip to content

Issue with child actions not being executed when scoping with if let store = store.scope #3556

Answered by mbrandonw
tommy-holmes asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @tommy-holmes, the problem is in your AppReducer:

var body: some ReducerOf<Self> {
  Reduce { state, action in
    switch action {
    case .onAppear:
      state = .home(.init(data: ["Hello", "World"]))
      return .none
    case .home: return .none
    case .login: return .none
    }
  }
}

While you have integrated the domains of home and login into the app feature, you have not integrated their reducers. You can do so like this:

var body: some ReducerOf<Self> {
  Scope(state: \.home, action: \.home) {
    Home()
  }
  Scope(state: \.login, action: \.login) {
    Login()
  }
  Reduce { state, action in
    switch action {
    case .onAppear:
      state = .home(.init(data: ["Hello", "

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tommy-holmes
Comment options

Answer selected by tommy-holmes
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