如何将多减速器合并到同一级别状态

时间:2017-01-02 10:09:01

标签: reactjs redux react-redux

我想要了解结构状态。

{
     product: {
         items: [],
         fetching: true,
         selected: []
     }
}

项目&提取由HttpReducer处理,选择由ProductSelectReducer处理,如何将多个Reducer的状态合并到同一级别?

感谢。

1 个答案:

答案 0 :(得分:1)

减速器/ product.js:

import { combineReducers } from 'redux'

const items = HttpReducer(...)
const fetching = HttpReducer(...)
const selected = ProductSelectReducer(...)

export default combineReducers(
  items,
  fetching,
  selected,
)

减速器/ index.js:

import { combineReducers } from 'redux'
import productReducer from './products'

export default combineReducers(
  product: productReducer,
)

此缩减器结构将导致您正在寻找的结构。