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

172
Views
How I can change the combineReducers depends the user type

I have the next rootReducer that's init the app with the data user and charge the init data for the plataform.

export const rootReducer = combineReducers({
auth: authReducer,
ui: uiReducer,
dashboard: dashboardReducer
});

But my problem is when the user coming I have the type of that user and with that type I want to charge the data for the dashboard depends that field, I trying with another reducer that charge the correspond reducer but I can't:

export const dashboardReducer = (state=initialState, action) => {

switch (action.type) {

    case types.dashboardAdmin:
        return {
            ...state,
            dashboard: {adminRootReducer}
        };

    case types.dashboardTeacher:
        return {
            dashboard: {teacherRootReducer}
        }

    case types.dashboardStudent:
        return {
            ...state,
            dashboard: {studentRootReducer}
        }
    
    default:
        return state;
  }

}

Every root reducer is a combineReducers but I can't return the correponds reducers:

export const teacherRootReducer = 
combineReducers({
admin: adminReducer,
});

I want to charge the correspond root for every type that set on my app.

about 4 years ago · Juan Pablo Isaza
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!