一个 Redux 动作可以影响状态树的多个部分吗?
Can a Redux action affect multiple parts of the state tree?
影响 Redux 状态树多个部分的动作的共识是什么?
例如:
const ADD_POST = 'POST/ADD';
function postsReducer(state = initialState, action = {}) {
// switch ...
case ADD_POST:
return {
...state,
...action.result.post
}
}
function anotherReducer(state = initialState, action = {}) {
// switch ...
case ADD_POST:
return {
...state,
post_id: action.result.post.id
}
}
我正在就以下方面寻求建议:
影响 redux 多个部分的操作 store/state
是的,没关系。如果那是你想要发生的事情。
是的,绝对是。这就是动作存在的全部原因:将组件的角度发生的事情与状态变化方面实际发生的事情分开。
影响 Redux 状态树多个部分的动作的共识是什么?
例如:
const ADD_POST = 'POST/ADD';
function postsReducer(state = initialState, action = {}) {
// switch ...
case ADD_POST:
return {
...state,
...action.result.post
}
}
function anotherReducer(state = initialState, action = {}) {
// switch ...
case ADD_POST:
return {
...state,
post_id: action.result.post.id
}
}
我正在就以下方面寻求建议:
影响 redux 多个部分的操作 store/state
是的,没关系。如果那是你想要发生的事情。
是的,绝对是。这就是动作存在的全部原因:将组件的角度发生的事情与状态变化方面实际发生的事情分开。