javascript - 组合组合 reducer

标签 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: {...}
}

我试过 ...reducers 但没有成功。提前致谢

最佳答案

你可以拥有一个包含所有 reducer 的对象,

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

然后你就可以

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

关于javascript - 组合组合 reducer ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48047038/

相关文章:

javascript - 使用包含 .getValue() 的自动脚本时如何绕过单元格中的空白值

javascript - 更改 socket.on ("data"的回调,fn) nodejs

javascript - ES6 中解构对象作为参数

javascript - 在 Ember-CLI 的应用程序初始化程序中注入(inject)?

javascript - 使用 ES6/Harmony 以 FP 方式创建具有相同值和键的映射

redux 中的 reducer 中的验证

javascript - 发生Redux状态更改时,组件不会更新

Javascript - 通过知道索引查找数组中项目的值

javascript - React Redux 重新选择 - 未定义状态

javascript - 如何使用javascript连接到另一台服务器上的php