reducer switch ์กฐ๊ฑด๋ฌธ

์ตœ๊ทผ์— redux๋ฅผ ๋ฐฐ์› ๋Š”๋ฐ, Reducer ๋ถ€๋ถ„์— ์ž ๊น ๋“ฑ์žฅํ–ˆ๋˜ switch ๋ฌธ๋ฒ•์— ๋Œ€ํ•ด์„œ ๋‹ค๋ค„๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์ •๋ง ๊ฐ„๋‹จํ•œ ํฌ์ŠคํŒ…์ž…๋‹ˆ๋‹ค. ์‰ฌ์–ด๊ฐ€๊ธฐ... Reducer๋Š” Dispatch์—๊ฒŒ์„œ ์ „๋‹ฌ๋ฐ›์€ Action ๊ฐ์ฒด์˜ type ๊ฐ’์— ๋”ฐ๋ผ์„œ ์ƒํƒœ๋ฅผ ๋ณ€๊ฒฝ์‹œํ‚ค๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. ๋‹ค์Œ์€ Reducer์—์„œ switch ๊ตฌ๋ฌธ์„ ํ™œ์šฉํ•œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ๋ณด์ด๋Š” ๊ฒƒ์ฒ˜๋Ÿผ Reducer๋Š” Action ๊ฐ์ฒด์˜ type ๊ฐ’์— ๋”ฐ๋ผ ๋ถ„๊ธฐํ•˜๋Š” switch ์กฐ๊ฑด๋ฌธ์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. const count = 1 // Reducer๋ฅผ ์ƒ์„ฑํ•  ๋•Œ์—๋Š” ์ดˆ๊ธฐ ์ƒํƒœ๋ฅผ ์ธ์ž๋กœ ์š”๊ตฌํ•ฉ๋‹ˆ๋‹ค. const counterReducer = (state = count, action) => { // Action ๊ฐ์ฒด์˜ type ๊ฐ’์— ๋”ฐ๋ผ ๋ถ„๊ธฐํ•˜๋Š” swit..
becky(์ง€์€)
'reducer switch ์กฐ๊ฑด๋ฌธ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก