Redux分层减速器

时间:2018-08-03 08:57:42

标签: reactjs redux react-redux

我想知道我是否可以这样嵌套减速器。

var combinedReducers  = {
        Tasks: TaskDuck.reducer,
        Approval:  {
                ApprovalDetail: ApprovalDuck.reducer ,
                ApprovalDecisions: DecisionsTasksDuck.reducer 
            } 
    };

    export const rootReducer = Redux.combineReducers<AppState>(combinedReducers);

2 个答案:

答案 0 :(得分:0)

combineReducers属性应该映射到函数,而不是对象。正如您在这里看到的那样,我添加了一个函数,该函数返回预期的对象,并且它起作用。

 dataType: "json",
        data:{email:email,password:password},
        success:function(data){
            if(data.status == 'ok'){
                $.each(data, function(index, e) {

                $('#user_id').text(e.user_id);
                $('#email').text(e.email);
                $('#form_email').value = text(e.email);

答案 1 :(得分:0)

您已经关闭。您可以多次拨打combineReducers()。对于您的示例,您需要:

const rootReducer = combineReducers({
    Tasks : TaskDuck.reducer,
    Approval : combineReducers({
        ApprovalDetail : ApprovalDuck.reducer,
        ApprovalDecisison : DecisionsTaskDuck.reducer
    })
});