Redux: `combineReducers` ๋ฌธ์„œ๋Š” ๋ฆฌ๋“€์„œ์— ์ „๋‹ฌํ•  ์ƒํƒœ ๋ถ€๋ถ„์„ ์ถ”์ธกํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2015๋…„ 08์›” 08์ผ  ยท  7์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: reduxjs/redux

์ƒˆ๋กœ์šด CombineReducers ๋ฌธ์„œ๋Š” ๊ดœ์ฐฎ์ง€๋งŒ, ๋ฆฌ๋“€์„œ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ƒํƒœ์˜ ๋‹น์‚ฌ์ž๋กœ ์ด๋ฆ„์„ ์ง€์ •ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์„ค๋ช…์€ ์—†์Šต๋‹ˆ๋‹ค.

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

ํ”ผ๋“œ๋ฐฑ ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๋งค์šฐ ๊ฐ€์น˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‚˜๋Š” ๊ทธ๊ฒƒ์„ ๊ฐ•์กฐํ•˜๊ณ  ์‹ถ๋‹ค

์ปจ๋ฒค์…˜์€ API์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค

์‚ฌ์‹ค์ด ์•„๋‹™๋‹ˆ๋‹ค.

๋ฌธ์„œ์—์„œ import * ๋Š” ํ”ผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์™œ๋ƒํ•˜๋ฉด ์‚ฌ๋žŒ๋“ค์€ ์ด๊ฒƒ์ด API์˜ ํ•„์ˆ˜์ ์ธ ๋ถ€๋ถ„์ด ์•„๋‹ ๋•Œ ํ•„์ˆ˜ ์š”์†Œ๋ผ๊ณ  ๊ฐ€์ •ํ•˜๊ณ  ์ œ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ํŽธ๋ฆฌํ•œ ๋ฐ”๋กœ ๊ฐ€๊ธฐ์ผ ๋ฟ์ž…๋‹ˆ๋‹ค.

ํ•จ์ˆ˜ ์ด๋ฆ„์€ ES6 export ๋ฐ import * as ์ž‘๋™ ๋ฐฉ์‹ ๋•Œ๋ฌธ์— ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

Btw, ๋‚˜๋Š” ์—ฌ์ „ํžˆ ์ƒํƒœ์˜ ํ•˜์œ„ ๋ถ€๋ถ„์„ ๊ฐ์†๊ธฐ์— ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์˜์•„ํ•ดํ•ฉ๋‹ˆ๋‹ค. ๋‚ด๊ฐ€ camelCase ๊ทธ๋“ค ๋˜๋Š” ๋ญ”๊ฐ€ ๊ฐ€์ž…ํ•ด์•ผํ•ฉ๋‹ˆ๊นŒ? state={์†Œ์œ ์ž: {์ด๋ฆ„: 'John'} } โ†’ export function ownerName(state = [], action)?

์•„๋‹ˆ :-). ๊ทธ๊ฒƒ์€ ๋งˆ๋ฒ•์˜ API๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. combineReducers(object) ๋Š” ์—ฌ๋Ÿฌ ๊ฐ์†๊ธฐ๋ฅผ ํ•˜๋‚˜๋กœ ๊ฒฐํ•ฉํ•˜๊ณ  ์ œ๊ณตํ•œ ํ‚ค๋กœ ์ƒํƒœ์˜ ์ผ๋ถ€๋ฅผ ๊ฐ’์œผ๋กœ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค. ์ •ํ™•ํžˆ ํ•œ ์ˆ˜์ค€ ๊นŠ์ด์—์„œ๋งŒ ์ด ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. "๋‚˜๋ฌด ์ „์ฒด๋ฅผ ๋งŒ๋“œ๋Š” ๋งˆ๋ฒ•"์€ ์—†์Šต๋‹ˆ๋‹ค. ๊ฐ์†๊ธฐ๋ฅผ ๋” ๋งŽ์€ ๊ธฐ๋Šฅ์œผ๋กœ ๋‚˜๋ˆ„๋Š” ๊ฒƒ์€ ๋‹น์‹ ์—๊ฒŒ ๋‹ฌ๋ ค ์žˆ์Šต๋‹ˆ๋‹ค.

// Function names don't matter!
function processA(state, action) { ... }
function doSomethingWithB(state, action) { ... }

function reducer(state = {}, action) {
  return {
    // Because you call them!
    a: processA(state.a, action),
    b: doSomethingWithB(state.b, action)
  };
}

// Not using combineReducers
let store = createStore(reducer);

์ง์ ‘ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•œ combineReducers ๋„์šฐ๋ฏธ ๋ฅผ ์‚ฌ์šฉํ•ด ๋„ ์ƒ๊ด€ ์—†์Šต๋‹ˆ๋‹ค.

// Function names don't matter!
function processA(state, action) { ... }
function doSomethingWithB(state, action) { ... }

/*
function reducer(state = {}, action) {
  return {
    a: processA(state.a, action),
    b: doSomethingWithB(state.b, action)
  };
}
*/
let reducer = combineReducers({
  a: processA,
  b: doSomethingWithB
});

let store = createStore(reducer);

์ด ์ž‘์—…์„ ์—ฌ๋Ÿฌ ๋ฒˆ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ „์—:

// Function names don't matter!
function processSomePartOfA(state, action) { ... }
function doSomethingWithOtherPartOfA(state, action) { ... }

function processA(state, action) {
  return {
    // Because you call them!
    somePart: processSomePartOfA(state.somePart),
    otherPart: doSomethingWithOtherPartOfA(state.otherPart)
  }
}
function doSomethingWithB(state, action) { ... }

function reducer(state = {}, action) {
  return {
    // Because you call them!
    a: processA(state.a, action),
    b: doSomethingWithB(state.b, action)
  };
}

// Not using the helper
let store = createStore(reducer);

์•Œ๊ฒ ์–ด? ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ํ•จ์ˆ˜์ผ ๋ฟ์ž…๋‹ˆ๋‹ค. ๋งˆ๋ฒ•์˜ "๊นŠ์€ ๋ฌผ๊ฑด"์ด ์—†์Šต๋‹ˆ๋‹ค.
combineReducers ์—ฌ๋Ÿฌ ๋ฒˆ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

// Function names don't matter!
function processSomePartOfA(state, action) { ... }
function doSomethingWithOtherPartOfA(state, action) { ... }

/*
function processA(state, action) {
  return {
    somePart: processSomePartOfA(state.somePart),
    otherPart: doSomethingWithOtherPartOfA(state.otherPart)
  }
}
*/
let processA = combineReducers({
  somePart: processSomePartOfA,
  otherPart: doSomethingWithOtherPartOfA
});

function processA(state, action) { ... }
function doSomethingWithB(state, action) { ... }

/*
function reducer(state = {}, action) {
  return {
    a: processA(state.a, action),
    b: doSomethingWithB(state.b, action)
  };
}
*/
let reducer = combineReducers({
  a: processA,
  b: doSomethingWithB
});

let store = createStore(reducer);

๋ฌธ์ œ ํ•จ์ˆ˜ ์ด๋ฆ„์€ ์‚ฌ์šฉํ•  ๋•Œ์ž…๋‹ˆ๋‹ค ์œ ์ผํ•œ ๋ถ€๋ถ„ export + import * as ์— ๋‹น์‹ ์ด์— ์ „๋‹ฌ ๊ฐ์ฒด "์ทจ๋“" combineReducers _that์ด๊ธฐ ๋•Œ๋ฌธ์— ์–ผ๋งˆ๋‚˜ import * works_ ! ๋‚ด๋ณด๋‚ด๊ธฐ ํ‚ค๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฌผ๊ฑด์„ ๊ฐ์ฒด์— ๋„ฃ์Šต๋‹ˆ๋‹ค.

๋‚ด ๊ฐ€์žฅ ํฐ ์‹ค์ˆ˜๋Š” ๋…์ž๊ฐ€ ๋ช…๋ช…๋œ ๋‚ด๋ณด๋‚ด๊ธฐ์— ์ต์ˆ™ํ•˜๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋ชจ๋“  7 ๋Œ“๊ธ€

๊ฑด๋„ˆ ๋›ฐ์ง€ ์•Š๊ณ  ์™„์ „ํžˆ ์ฝ์œผ๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋งํ•ฉ๋‹ˆ๋‹ค.

๊ฒฐ๊ณผ ๋ฆฌ๋“€์„œ๋Š” ๋ชจ๋“  ์ž์‹ ๋ฆฌ๋“€์„œ๋ฅผ ํ˜ธ์ถœํ•˜๊ณ  ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ๋‹จ์ผ ์ƒํƒœ ๊ฐ์ฒด๋กœ ์ˆ˜์ง‘ํ•ฉ๋‹ˆ๋‹ค. ์ƒํƒœ ๊ฐ์ฒด์˜ ๋ชจ์–‘์€ ์ „๋‹ฌ๋œ ๋ฆฌ๋“€์„œ์˜ ํ‚ค์™€ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋Ÿฌ๋‚˜ ์‚ฌ๋žŒ๋“ค์ด ์ข…์ข… ์ด ๋ฌธ์žฅ์„ ๋†“์น˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๊ฒƒ์ด ๋” ๋‘๋“œ๋Ÿฌ์ ธ์•ผ ํ•œ๋‹ค๋Š” ๋ฐ ๋™์˜ํ•ฉ๋‹ˆ๋‹ค.
#399์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ๋„์›€์ด ๋ ๊นŒ์š”?

๋‚˜๋Š” ์ปดํ“จํ„ฐ ๊ณผํ•™์„ ๋œ ์„ ํ˜ธํ•˜๊ณ , ์˜ˆ๋ฅผ ๋“  ์งํ›„์— ์ด ๊ทœ์น™ ์— ๋Œ€ํ•ด ๋ช…์‹œ์ ์œผ๋กœ ์–ธ๊ธ‰ํ•ฉ๋‹ˆ๋‹ค.

๋ฆฌ๋“€์„œ์˜ ์ด๋ฆ„์€ todos ๋ฐ counter -- ์ •ํ™•ํžˆ ์šฐ๋ฆฌ๊ฐ€ ์ „๋‹ฌํ•˜๋Š” ์ƒํƒœ์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค.

์ƒํƒœ์˜ ์ผ๋ถ€๋ฅผ ๋ฆฌ๋“€์Šค์— ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•ด Redux๋Š” _convention_์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ฆฌ๋“€์„œ๋Š” ์ „๋‹ฌํ•˜๋ ค๋Š” ์ƒํƒœ์˜ ์ผ๋ถ€๋กœ ์ •ํ™•ํžˆ ์ด๋ฆ„์„ ์ง€์ • ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

#399๊ฐ€ ์ข‹์€ ๊ฒƒ ๊ฐ™์ง€๋งŒ _Flux ์‚ฌ์šฉ์ž_๋ฅผ ์œ„ํ•œ ์„ค๋ช…์ž…๋‹ˆ๋‹ค. ๋‚˜๋Š” ๋ณดํŠธ์˜ ์‹ ์„ ํ•œ Redux์— ์˜ค๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋‚ด ํ…์ŠคํŠธ์˜ ์ผ๋ถ€ ํ˜•ํƒœ๋Š” ์บ์ฃผ์–ผ JavaScript ๊ฐœ๋ฐœ์ž์—๊ฒŒ ๋” ๋„์›€์ด ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์ค‘์š”ํ•œ ์•„์ด๋””์–ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๊ทœ์น™์€ API์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค . ์ด๋Š” createRedux , createDispatcher ๋ฐ ๊ธฐํƒ€ API ํ•จ์ˆ˜์—๋„ ๋˜‘๊ฐ™์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. API์˜ ์ผ๋ถ€์ด๊ธฐ ๋•Œ๋ฌธ์— ํ•ญ์ƒ ๋ช…์‹œ์ ์œผ๋กœ ๊ทœ์•ฝ์„ ๋ช…์‹œํ•˜์‹ญ์‹œ์˜ค.

Btw, ๋‚˜๋Š” ์—ฌ์ „ํžˆ ์ƒํƒœ์˜ ํ•˜์œ„ ๋ถ€๋ถ„์„ ๊ฐ์†๊ธฐ์— ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์˜์•„ํ•ดํ•ฉ๋‹ˆ๋‹ค. ๋‚ด๊ฐ€ camelCase ๊ทธ๋“ค ๋˜๋Š” ๋ญ”๊ฐ€ ๊ฐ€์ž…ํ•ด์•ผํ•ฉ๋‹ˆ๊นŒ? state={owner: {name: 'John'} } โ†’ export function ownerName(state = [], action) ?

ํ”ผ๋“œ๋ฐฑ ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๋งค์šฐ ๊ฐ€์น˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‚˜๋Š” ๊ทธ๊ฒƒ์„ ๊ฐ•์กฐํ•˜๊ณ  ์‹ถ๋‹ค

์ปจ๋ฒค์…˜์€ API์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค

์‚ฌ์‹ค์ด ์•„๋‹™๋‹ˆ๋‹ค.

๋ฌธ์„œ์—์„œ import * ๋Š” ํ”ผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์™œ๋ƒํ•˜๋ฉด ์‚ฌ๋žŒ๋“ค์€ ์ด๊ฒƒ์ด API์˜ ํ•„์ˆ˜์ ์ธ ๋ถ€๋ถ„์ด ์•„๋‹ ๋•Œ ํ•„์ˆ˜ ์š”์†Œ๋ผ๊ณ  ๊ฐ€์ •ํ•˜๊ณ  ์ œ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ํŽธ๋ฆฌํ•œ ๋ฐ”๋กœ ๊ฐ€๊ธฐ์ผ ๋ฟ์ž…๋‹ˆ๋‹ค.

ํ•จ์ˆ˜ ์ด๋ฆ„์€ ES6 export ๋ฐ import * as ์ž‘๋™ ๋ฐฉ์‹ ๋•Œ๋ฌธ์— ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

Btw, ๋‚˜๋Š” ์—ฌ์ „ํžˆ ์ƒํƒœ์˜ ํ•˜์œ„ ๋ถ€๋ถ„์„ ๊ฐ์†๊ธฐ์— ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์˜์•„ํ•ดํ•ฉ๋‹ˆ๋‹ค. ๋‚ด๊ฐ€ camelCase ๊ทธ๋“ค ๋˜๋Š” ๋ญ”๊ฐ€ ๊ฐ€์ž…ํ•ด์•ผํ•ฉ๋‹ˆ๊นŒ? state={์†Œ์œ ์ž: {์ด๋ฆ„: 'John'} } โ†’ export function ownerName(state = [], action)?

์•„๋‹ˆ :-). ๊ทธ๊ฒƒ์€ ๋งˆ๋ฒ•์˜ API๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. combineReducers(object) ๋Š” ์—ฌ๋Ÿฌ ๊ฐ์†๊ธฐ๋ฅผ ํ•˜๋‚˜๋กœ ๊ฒฐํ•ฉํ•˜๊ณ  ์ œ๊ณตํ•œ ํ‚ค๋กœ ์ƒํƒœ์˜ ์ผ๋ถ€๋ฅผ ๊ฐ’์œผ๋กœ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค. ์ •ํ™•ํžˆ ํ•œ ์ˆ˜์ค€ ๊นŠ์ด์—์„œ๋งŒ ์ด ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. "๋‚˜๋ฌด ์ „์ฒด๋ฅผ ๋งŒ๋“œ๋Š” ๋งˆ๋ฒ•"์€ ์—†์Šต๋‹ˆ๋‹ค. ๊ฐ์†๊ธฐ๋ฅผ ๋” ๋งŽ์€ ๊ธฐ๋Šฅ์œผ๋กœ ๋‚˜๋ˆ„๋Š” ๊ฒƒ์€ ๋‹น์‹ ์—๊ฒŒ ๋‹ฌ๋ ค ์žˆ์Šต๋‹ˆ๋‹ค.

// Function names don't matter!
function processA(state, action) { ... }
function doSomethingWithB(state, action) { ... }

function reducer(state = {}, action) {
  return {
    // Because you call them!
    a: processA(state.a, action),
    b: doSomethingWithB(state.b, action)
  };
}

// Not using combineReducers
let store = createStore(reducer);

์ง์ ‘ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•œ combineReducers ๋„์šฐ๋ฏธ ๋ฅผ ์‚ฌ์šฉํ•ด ๋„ ์ƒ๊ด€ ์—†์Šต๋‹ˆ๋‹ค.

// Function names don't matter!
function processA(state, action) { ... }
function doSomethingWithB(state, action) { ... }

/*
function reducer(state = {}, action) {
  return {
    a: processA(state.a, action),
    b: doSomethingWithB(state.b, action)
  };
}
*/
let reducer = combineReducers({
  a: processA,
  b: doSomethingWithB
});

let store = createStore(reducer);

์ด ์ž‘์—…์„ ์—ฌ๋Ÿฌ ๋ฒˆ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ „์—:

// Function names don't matter!
function processSomePartOfA(state, action) { ... }
function doSomethingWithOtherPartOfA(state, action) { ... }

function processA(state, action) {
  return {
    // Because you call them!
    somePart: processSomePartOfA(state.somePart),
    otherPart: doSomethingWithOtherPartOfA(state.otherPart)
  }
}
function doSomethingWithB(state, action) { ... }

function reducer(state = {}, action) {
  return {
    // Because you call them!
    a: processA(state.a, action),
    b: doSomethingWithB(state.b, action)
  };
}

// Not using the helper
let store = createStore(reducer);

์•Œ๊ฒ ์–ด? ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ํ•จ์ˆ˜์ผ ๋ฟ์ž…๋‹ˆ๋‹ค. ๋งˆ๋ฒ•์˜ "๊นŠ์€ ๋ฌผ๊ฑด"์ด ์—†์Šต๋‹ˆ๋‹ค.
combineReducers ์—ฌ๋Ÿฌ ๋ฒˆ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

// Function names don't matter!
function processSomePartOfA(state, action) { ... }
function doSomethingWithOtherPartOfA(state, action) { ... }

/*
function processA(state, action) {
  return {
    somePart: processSomePartOfA(state.somePart),
    otherPart: doSomethingWithOtherPartOfA(state.otherPart)
  }
}
*/
let processA = combineReducers({
  somePart: processSomePartOfA,
  otherPart: doSomethingWithOtherPartOfA
});

function processA(state, action) { ... }
function doSomethingWithB(state, action) { ... }

/*
function reducer(state = {}, action) {
  return {
    a: processA(state.a, action),
    b: doSomethingWithB(state.b, action)
  };
}
*/
let reducer = combineReducers({
  a: processA,
  b: doSomethingWithB
});

let store = createStore(reducer);

๋ฌธ์ œ ํ•จ์ˆ˜ ์ด๋ฆ„์€ ์‚ฌ์šฉํ•  ๋•Œ์ž…๋‹ˆ๋‹ค ์œ ์ผํ•œ ๋ถ€๋ถ„ export + import * as ์— ๋‹น์‹ ์ด์— ์ „๋‹ฌ ๊ฐ์ฒด "์ทจ๋“" combineReducers _that์ด๊ธฐ ๋•Œ๋ฌธ์— ์–ผ๋งˆ๋‚˜ import * works_ ! ๋‚ด๋ณด๋‚ด๊ธฐ ํ‚ค๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฌผ๊ฑด์„ ๊ฐ์ฒด์— ๋„ฃ์Šต๋‹ˆ๋‹ค.

๋‚ด ๊ฐ€์žฅ ํฐ ์‹ค์ˆ˜๋Š” ๋…์ž๊ฐ€ ๋ช…๋ช…๋œ ๋‚ด๋ณด๋‚ด๊ธฐ์— ์ต์ˆ™ํ•˜๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋‚ด ๊ฐ€์žฅ ํฐ ์‹ค์ˆ˜๋Š” ๋…์ž๊ฐ€ ๋ช…๋ช…๋œ ๋‚ด๋ณด๋‚ด๊ธฐ์— ์ต์ˆ™ํ•˜๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋…์ž๊ฐ€ ES6์— ์ต์ˆ™ํ•˜๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋Š” ๊ฒƒ์€ ๋ฌด๋ฆฌ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๊ทธ๊ฒƒ์ด ์‚ฌ๋žŒ๋“ค์ด ๋ฐฐ์šฐ๊ณ  ์ด๊ฒƒ์„ ์•Œ์•„๋‚ด๋„๋ก ๋งŒ๋“œ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ฝ๊ธฐ๊ฐ€ ๋…์ž์˜ ์ง€์‹๊ณผ ๊ฒฝํ—˜๋ณด๋‹ค ์•ž์„œ ์žˆ๋‹ค๋Š” ๊ฒƒ์€ ์‹ค์ œ๋กœ ์ข‹์€ ์ผ์ž…๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋Š” ๋ช…์‹œ ์ ์œผ๋กœ ํ˜ธ์ถœํ•˜๋Š” ์˜ˆ์ œ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ  combineReducers ์—์„œ reducers/index ๊ฐ€ ์ง€๊ธˆ๋ถ€ํ„ฐ ๋” ์˜๋ฏธ๋ฅผ ๋งŒ๋“ค๋ ค๊ณ , ๊ทธ๋ž˜์„œ ํฌ๋ง : https://github.com/gaearon/redux/pull/473

์ด๊ฒƒ์€ ํ˜„์žฌ ๋ฌธ์„œ์—์„œ ๋” ์ž˜ ๋‹ค๋ฃจ์–ด์ง€๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‹ซ์Šต๋‹ˆ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ๋ฌธ์„œ์—์„œ๋„ ๋” ์ด์ƒ import * ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฐ ์•”์‹œ์  ๋™์ž‘์„ ํฌํ•จํ•˜๋Š” ๊ฒƒ์ด ์ข‹์€ ์ฝ”๋”ฉ ๋ฐฉ๋ฒ•์ด๋ผ๊ณ  ์ •๋ง ์ƒ๊ฐํ•˜์‹ญ๋‹ˆ๊นŒ?

๋‚˜์—๊ฒŒ ๊ทธ๊ฒƒ์€ ์ฝ”๋“œ๋ฅผ ๋‚œ๋…ํ™”ํ•˜๊ณ  CombineReducer๊ฐ€ ์กด์žฌํ•ด์„œ๋Š” ์•ˆ๋˜๋ฉฐ, ๋ถˆํ•„์š”ํ•œ ์ถ”์ƒํ™” ๋‹จ๊ณ„๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ํ”„๋กœ์„ธ์Šค๋ฅผ ๋ณต์žกํ•˜๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ์ด์™€ ๊ฐ™์€ ์ค‘์š”ํ•œ ๊ธฐ๋Šฅ์€ ์‰ฝ๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด "๋งˆ๋ฒ• ๊ฐ™์€" ๋Š๋‚Œ์€ ๊ทธ๋ ‡์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ถ”์‹  : ๋‚˜๋Š” ๊ณต์‹ Redux ๋ฌธ์„œ์—์„œ ์™”์Šต๋‹ˆ๋‹ค : "๋งˆ๋ฒ•์ด ์•„๋‹™๋‹ˆ๋‹ค"

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰