结合减速机组合

问题描述 投票:1回答:1
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: {...}
}

我试过......减速器,但那不起作用。提前致谢

javascript ecmascript-6 redux reducers
1个回答
2
投票

你可以拥有一个包含所有减速器的物体,

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

然后你就可以了

const rootReducer = combineReducers ({
   form: formReducer,
   apollo: apolloReducer,
   ...reducers
})
© www.soinside.com 2019 - 2024. All rights reserved.