1
是否差想法使用还原剂中的条件?类似这样的:还原剂中的条件
case types.SET_SOME_ACTION:
if(typeof someElement !== "undefined") {
return Object.assign({}, state, {
someElement: action.value
})
}
试图看看这是否是反模式。谢谢。
我完全同意你的回答。然而,我正在处理一个有趣的场景,到目前为止我唯一提出的解决方案是在reducer中使用一个条件 - 我不想这样做。这是这种情况:https://stackoverflow.com/questions/45874594/handling-one-property-effecting-the-state-of-other – Sam