Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda