Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!