这是我的组合减速器:
export const element = (state, action) => {
...
}
export const elementSelection = (state, action) => {
...
}
const holoApp = combineReducers({
elements,
elementSelection
})
elementSelection的状态保存当前选定的元素。我希望能够根据当前选择的元素在elementsReducer中分派操作。
例如,如果store.getState().elementSelection.elementType等于"placeholder“,则此操作将被忽略:
store.dispatch(replaceElement(...));
否则此操作将被调度:
store.dispatch(addElement(...));
我唯一的猜测是把这个逻辑放在app类中,它由store组成,我想知道这是否是根据交叉缩减状态调度操作的最佳实践。
https://stackoverflow.com/questions/38287252
复制相似问题