slice reducer 간 데이터 공유하기
1. comebineReducer 함수 내부에서 action에 따라 slice Reducer에게 추가 인자 전달하기
function combinedReducer(state, action) {
switch (action.type) {
case 'A_TYPICAL_ACTION': {
return {
a: sliceReducerA(state.a, action),
b: sliceReducerB(state.b, action)
};
}
case 'SOME_SPECIAL_ACTION': {
return {
// specifically pass state.b as an additional argument
a: sliceReducerA(state.a, action, state.b),
b: sliceReducerB(state.b, action)
};
}
case 'ANOTHER_SPECIAL_ACTION': {
return {
a: sliceReducerA(state.a, action),
// specifically pass the entire state as an additional argument
b: sliceReducerB(state.b, action, state)
};
}
default:
return state;
}
}2. action의 payload에 추가 데이터 주기
3. combineReducer 로 생성된 리듀서를 이용하여 처리하기
Last updated
Was this helpful?