Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
redux: nested reducer access another store section

I use redux's combineReducers() helper function to combine two reducers like so:

const rootReducer = combineReducers({
  user: userReducer,
  accounts: accountsReducer
})

I know each reducer can only modify a slice of the store it's assigned to, "user" and "accounts" in this case.

How can i modify the "user" part of my store from my accounts reducer?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can't.

You can either listen to the same action in both reducers, or if you need to update the user state based on the update to the accounts' state, then you can use Redux thunks - https://github.com/gaearon/redux-thunk

const action = () => (dispatch, getState) => {
  // dispatch action that accounts reducer listens to
  dispatch({
    type: 'SOME_ACTION'
  })

  // get the new accounts state
  let { accounts } = getState()

  // dispatch action that user reducer listens to, passing the new accounts state
  dispatch({
    type: 'ANOTHER_ACTION',
    payload: {
      accounts
    }
  })
}

// call with
dispatch(action())
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda