인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

herman's profile image
herman

asked

Practical React Programming

Reducer, Store

createReducer 질문있습니다

Written on

·

179

0

function createReducer(init,handlerMap){

return function(state = init, action) {

return produce(state,draft =>{

....

}

}

}

return function(state = init, action) 이 부분이 이해가 안됩니다.

리듀서 만들 때 function createReducer(state = init, action ) {

switch(action.type) {

...

}

}

이런식으로 만들고 있었는데요  이 방법이 아닌

굳이 init , handlerMap을 사용하신 이유가 있을까요 ?? 

function(state = init , action ) 이렇게 한번에 적으면 단점이 있을까요 ? 

reactredux

Answer 2

1

landvibe님의 프로필 이미지
landvibe
Instructor

안녕하세요
handlerMap 을 사용한 이유는 7:40 부분에서 설명한 것 같습니다

저는 개인적으로 switch 보다는 map 형태로 리듀서 로직을 작성하는 게 편하다고 생각합니다
절대적인 것은 아니라서 switch 가 편하다고 생각하시면 그렇게 작성하시면 될 것 같아요^^

0

herman님의 프로필 이미지
herman
Questioner

감사합니다 선생님 ~

herman's profile image
herman

asked

Ask a question