结合减速机组合

时间:2018-01-01 03:56:24

标签: javascript ecmascript-6 redux reducers

export reducers = combineReducers ({
   app: ...,
   user: ...,
   display:...,
})

//在配置文件中

const rootReducer = combineReducers ({
   form: formReducer,
   apollo: apolloReducer,
   reducers
})

这会导致状态树看起来像这样,

{
  form: {...},
  apollo: {...},
  reducers: {
    app: {...},
    user: {...},
    display: {...}
  }
}

我想要这个......

{
  form: {...},
  apollo: {...},
  app: {...},
  user: {...},
  display: {...}
}

我试过......减速器但是没有用。提前致谢

1 个答案:

答案 0 :(得分:2)

你可以拥有一个包含所有缩减器的对象,

export reducers = {
   app: ...,
   user: ...,
   display:...,
}

然后你可以

const rootReducer = combineReducers ({
   form: formReducer,
   apollo: apolloReducer,
   ...reducers
})