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.