Read Me

http://ko.redux.js.org

์ตœ์‹  ๋ฌธ์„œ๋Š” http://ko.redux.js.org์œผ๋กœ ๋ฐฉ๋ฌธํ•˜์—ฌ ์ฃผ์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

Redux๋Š” ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์•ฑ์„ ์œ„ํ•œ ์˜ˆ์ธก ๊ฐ€๋Šฅํ•œ ์ƒํƒœ ์ปจํ…Œ์ด๋„ˆ์ž…๋‹ˆ๋‹ค. (์›Œ๋“œํ”„๋ ˆ์Šค ํ”„๋ ˆ์ž„์›Œํฌ์ธ Redux Framework์™€ ํ˜ผ๋™ํ•˜์ง€ ๋งˆ์„ธ์š”.)

Redux๋Š” ์—ฌ๋Ÿฌ๋ถ„์ด ์ผ๊ด€์ ์œผ๋กœ ๋™์ž‘ํ•˜๊ณ , ์„œ๋กœ ๋‹ค๋ฅธ ํ™˜๊ฒฝ(์„œ๋ฒ„, ํด๋ผ์ด์–ธํŠธ, ๋„ค์ดํ‹ฐ๋ธŒ)์—์„œ ์ž‘๋™ํ•˜๊ณ , ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์‰ฌ์šด ์•ฑ์„ ์ž‘์„ฑํ•˜๋„๋ก ๋„์™€์ค๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์— ๋”ํ•ด์„œ ์‹œ๊ฐ„์—ฌํ–‰ํ˜• ๋””๋ฒ„๊ฑฐ์™€ ๊ฒฐํ•ฉ๋œ ์‹ค์‹œ๊ฐ„ ์ฝ”๋“œ ์ˆ˜์ •๊ณผ ๊ฐ™์€ ํ›Œ๋ฅญํ•œ ๊ฐœ๋ฐœ์ž ๊ฒฝํ—˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

์—ฌ๋Ÿฌ๋ถ„์€ Redux๋ฅผ React๋‚˜ ๋‹ค๋ฅธ ๋ทฐ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Redux๋Š” ๋งค์šฐ ์ž‘์Šต๋‹ˆ๋‹ค (2kB, ์˜์กด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํฌํ•จ).

โ€‹โ€‹build statusโ€‹ โ€‹npm versionโ€‹ โ€‹npm downloadsโ€‹ โ€‹redux channel on discordโ€‹ โ€‹Changelog #187โ€‹โ€‹

Redux ๋ฐฐ์šฐ๊ธฐ

์—ฌ๋Ÿฌ๋ถ„์˜ ๋ฐฐ๊ฒฝ์ด๋‚˜ ํ•™์Šต๋ฐฉ๋ฒ•์— ๊ด€๊ณ„ ์—†์ด Redux๋ฅผ ๋ฐฐ์šฐ๋Š” ๋ฐ ๋„์›€์ด ๋  ์ˆ˜ ์žˆ๋„๋ก ์—ฌ๋Ÿฌ ์ข…๋ฅ˜์˜ ์ž๋ฃŒ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ธฐ์ดˆ๋ถ€ํ„ฐ

Redux๋ฅผ ์ฒ˜์Œ ์ ‘ํ•ด์„œ ๊ธฐ์ดˆ ๊ฐœ๋…์„ ์ดํ•ดํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด:

์ค‘๊ธ‰ ๊ฐœ๋…

Once you've picked up the basics of working with actions, reducers, and the store, you may have questions about topics like working with asynchronous logic and AJAX requests, connecting a UI framework like React to your Redux store, and setting up an application to use Redux:

์‹ค์ œ ์‚ฌ์šฉ

Going from a TodoMVC app to a real production application can be a big jump, but we've got plenty of resources to help:

Finally, Mark Erikson is teaching a series of Redux workshops through Workshop.me. Check the workshop schedule for upcoming dates and locations.

๋„์›€๊ณผ ๋…ผ์˜

The #redux channel of the Reactiflux Discord community is our official resource for all questions related to learning and using Redux. Reactiflux is a great place to hang out, ask questions, and learn - come join us!

๋” ๋‚˜์•„๊ฐ€๊ธฐ ์ „์—

Redux๋Š” ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ์— ์ข‹์€ ๋„๊ตฌ์ด์ง€๋งŒ ์—ฌ๋Ÿฌ๋ถ„์˜ ์ƒํ™ฉ์— ์ ๋‹นํ•œ์ง€๋Š” ๋”ฐ์ ธ ๋ณด์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹จ์ง€ ๋ˆ„๊ตฐ๊ฐ€๊ฐ€ ์‚ฌ์šฉํ•˜๋ผ๊ณ  ํ–ˆ๋‹ค๋Š” ์ด์œ ๋งŒ์œผ๋กœ Redux๋ฅผ ์‚ฌ์šฉํ•˜์ง€๋Š” ๋งˆ์„ธ์š” - ์‹œ๊ฐ„์„ ๋“ค์—ฌ์„œ ์ž ์žฌ์ ์ธ ์ด์ ๊ณผ ๊ทธ์— ๋”ฐ๋ฅธ ๋“ฑ๊ฐ€๊ตํ™˜์— ๋Œ€ํ•ด ์ดํ•ดํ•˜์„ธ์š”.

Redux๋ฅผ ์‚ฌ์šฉํ• ๋งŒํ•œ ์‹œ์ ์„ ์•Œ๊ธฐ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ์ œ์•ˆ์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  • ์‹œ๊ฐ„์— ๋”ฐ๋ผ ๋ฐ”๋€Œ๋Š” ์ถฉ๋ถ„ํ•œ ์–‘์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ๋‹ค

  • ์ƒํƒœ๋ฅผ ์œ„ํ•œ ๋‹จ ํ•˜๋‚˜์˜ ์›์ฒœ์ด ํ•„์š”ํ•˜๋‹ค

  • ๋ชจ๋“  ์ƒํƒœ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๊ธฐ์— ์ตœ์ƒ์œ„ ์ƒํƒœ๋Š” ๋” ์ด์ƒ ์ ๋‹นํ•˜์ง€ ์•Š๋‹ค

์ด๋Ÿฌํ•œ ๊ฐ€์ด๋“œ๋ผ์ธ์€ ์ฃผ๊ด€์ ์ด๊ณ  ์• ๋งคํ•˜์ง€๋งŒ, ๊ทธ๋Ÿด๋งŒํ•œ ์ด์œ ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ์˜ ์•ฑ์— Redux๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•  ์‹œ์ ์€ ์‚ฌ์šฉ์ž์— ๋”ฐ๋ผ ๋‹ค๋ฅด๊ณ  ์•ฑ์— ๋”ฐ๋ผ ๋‹ค๋ฆ…๋‹ˆ๋‹ค.

Redux๊ฐ€ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉ๋˜์–ด์•ผ ํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์—ฌ๋Ÿฌ ์ƒ๊ฐ๋“ค์„ ๋ณด๋ ค๋ฉด:

๊ฐœ๋ฐœ์ž ๊ฒฝํ—˜

Dan Abramov (Redux์˜ ์ œ์ž‘์ž)๋Š” Redux๋ฅผ "Hot Reloading with Time Travel"์ด๋ผ๋Š” React Europe ๋ฐœํ‘œ๋ฅผ ์œ„ํ•ด ์ž‘์—…ํ•˜๋ฉด์„œ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ์˜ ๋ชฉํ‘œ๋Š” ์ตœ์†Œํ•œ์˜ API๋ฅผ ๊ฐ€์ง€๋ฉด์„œ๋„ ์™„์ „ํžˆ ์˜ˆ์ธก ๊ฐ€๋Šฅํ•œ ํ–‰๋™์„ ํ•˜๋Š” ์ƒํƒœ ๊ด€๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋งŒ๋“ค์–ด์„œ, ์ด๋ฅผ ํ†ตํ•ด ๋กœ๊น…, ํ•ซ ๋ฆฌ๋กœ๋”ฉ, ์‹œ๊ฐ„์—ฌํ–‰, ์œ ๋‹ˆ๋ฒ„์…œ ์•ฑ, ๊ธฐ๋ก๊ณผ ์žฌ์ƒ ๋“ฑ์„ ๊ฐœ๋ฐœ์ž์˜ ๋…ธ๋ ฅ ์—†์ด๋„ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค.

์˜ํ–ฅ์„ ๋ฐ›์€ ๊ฒƒ๋“ค

Redux๋Š” Flux์˜ ์•„์ด๋””์–ด๋ฅผ ๋ฐœ์ „์‹œํ‚ค๋˜, Elm์˜ ํ๋“ค์„ ๊ฐ€์ ธ์˜ด์œผ๋กœ์จ ๋ณต์žก์„ฑ์€ ์ค„์˜€์Šต๋‹ˆ๋‹ค. ์ด๋“ค์„ ์จ๋ณด์…จ๋Š”์ง€์™€ ์ƒ๊ด€ ์—†์ด, Redux๋ฅผ ์‹œ์ž‘ํ•˜๋Š”๋ฐ๋Š” ๋ช‡ ๋ถ„์ด๋ฉด ์ถฉ๋ถ„ํ•ฉ๋‹ˆ๋‹ค.

์„ค์น˜

์•ˆ์ • ๋ฒ„์ „์„ ์„ค์น˜ํ•˜์‹œ๋ ค๋ฉด:

npm install --save redux

์ด๋Š” ์—ฌ๋Ÿฌ๋ถ„์ด npm์„ ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ ์•„๋‹ˆ๋ผ๋ฉด ์ด๋“ค ํŒŒ์ผ์„ unpkg์—์„œ ์ ‘๊ทผํ•ด์„œ ๋‹ค์šด๋กœ๋“œ๋ฐ›๊ฑฐ๋‚˜ ์—ฌ๋Ÿฌ๋ถ„์˜ ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €์— ์ง€์ •ํ•ด์ฃผ์„ธ์š”.

๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ๋žŒ๋“ค์€ Redux๋ฅผ CommonJS ๋ชจ๋“ˆ๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ชจ๋“ˆ์€ Webpack์ด๋‚˜ Browserify ๋˜๋Š” Node ํ™˜๊ฒฝ์—์„œ redux๋ฅผ ์ž„ํฌํŠธํ• ๋•Œ ๋ถˆ๋Ÿฌ์™€์ง‘๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ๋ถ„์ด ์ตœ์ฒจ๋‹จ์„ ๊ฑท๊ณ  ์žˆ์œผ๋ฉฐ Rollup์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ์ด ์—ญ์‹œ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ ์—ฌ๋Ÿฌ๋ถ„์ด ๋ชจ๋“ˆ ๋ฒˆ๋“ค๋Ÿฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์ง€ ์•Š๋”๋ผ๋„ ๊ดœ์ฐฎ์Šต๋‹ˆ๋‹ค. redux npm ํŒจํ‚ค์ง€๋Š” ๋ฏธ๋ฆฌ ์ปดํŒŒ์ผ๋œ ํ”„๋กœ๋•์…˜๊ณผ ๊ฐœ๋ฐœ์šฉ UMD ๋นŒ๋“œ๋ฅผ dist ํด๋”์— ํฌํ•จํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋“ค์€ ๋ฒˆ๋“ค๋Ÿฌ ์—†์ด ๋ฐ”๋กœ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๊ณ  ๋Œ€๋ถ€๋ถ„์˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ชจ๋“ˆ ๋กœ๋”๋‚˜ ํ™˜๊ฒฝ๊ณผ ํ˜ธํ™˜๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด UMD ๋นŒ๋“œ๋ฅผ ํŽ˜์ด์ง€ ์ƒ์˜ <script> ํƒœ๊ทธ์—์„œ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜ Bower๊ฐ€ ์„ค์น˜ํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. UMD ๋นŒ๋“œ๋Š” Redux๋ฅผ window.Redux ์ „์—ญ๋ณ€์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค.

Redux ์†Œ์Šค์ฝ”๋“œ๋Š” ES2015๋กœ ์ž‘์„ฑ๋˜์—ˆ์ง€๋งŒ CommonJS์™€ UMD ๋นŒ๋“œ ๋ชจ๋‘๋ฅผ ES5๋กœ ๋ฏธ๋ฆฌ ์ปดํŒŒ์ผํ•ด๋‘์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ชจ๋“  ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. Redux๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ์œ„ํ•ด Babel์ด๋‚˜ ๋ชจ๋“ˆ ๋ฒˆ๋“ค๋Ÿฌ๋ฅผ ์‚ฌ์šฉํ•  ํ•„์š”๋Š” ์—†์Šต๋‹ˆ๋‹ค.

๋ณด์กฐ ํŒจํ‚ค์ง€

์•„๋งˆ ์—ฌ๋Ÿฌ๋ถ„์€ React ๋ฐ”์ธ๋”ฉ๊ณผ ๊ฐœ๋ฐœ์ž ๋„๊ตฌ๋„ ํ•„์š”ํ•˜์‹ค๊ฒ๋‹ˆ๋‹ค.

npm install --save react-redux
npm install --save-dev redux-devtools

Redux ์ž์ฒด์™€๋Š” ๋‹ฌ๋ฆฌ Redux ์ƒํƒœ๊ณ„์˜ ๋งŽ์€ ํŒจํ‚ค์ง€๋“ค์€ UMD ๋นŒ๋“œ๋ฅผ ์ œ๊ณตํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ, ํŽธ์•ˆํ•œ ๊ฐœ๋ฐœ ๊ฒฝํ—˜์„ ์œ„ํ•ด Webpack์ด๋‚˜ Browserify ๊ฐ™์€ CommonJS ๋ชจ๋“ˆ ๋ฒˆ๋“ค๋Ÿฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋ฅผ ๊ถŒํ•ฉ๋‹ˆ๋‹ค.

The Gist

์—ฌ๋Ÿฌ๋ถ„์˜ ์•ฑ์˜ ์ƒํƒœ ์ „๋ถ€๋Š” ํ•˜๋‚˜์˜ ์Šคํ† ์–ด(store)์•ˆ์— ์žˆ๋Š” ๊ฐ์ฒด ํŠธ๋ฆฌ์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค. ์ƒํƒœ ํŠธ๋ฆฌ๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ์œ ์ผํ•œ ๋ฐฉ๋ฒ•์€ ๋ฌด์—‡์ด ์ผ์–ด๋‚ ์ง€ ์„œ์ˆ ํ•˜๋Š” ๊ฐ์ฒด์ธ ์•ก์…˜(action)์„ ๋ณด๋‚ด๋Š” ๊ฒƒ ๋ฟ์ž…๋‹ˆ๋‹ค. ์•ก์…˜์ด ์ƒํƒœ ํŠธ๋ฆฌ๋ฅผ ์–ด๋–ป๊ฒŒ ๋ณ€๊ฒฝํ• ์ง€ ๋ช…์‹œํ•˜๊ธฐ ์œ„ํ•ด ์—ฌ๋Ÿฌ๋ถ„์€ ๋ฆฌ๋“€์„œ(reducers)๋ฅผ ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ด๊ฒŒ ๋‹ค์ž…๋‹ˆ๋‹ค!

import { createStore } from 'redux'
โ€‹
/**
* ์ด๊ฒƒ์ด (state, action) => state ํ˜•ํƒœ์˜ ์ˆœ์ˆ˜ ํ•จ์ˆ˜์ธ ๋ฆฌ๋“€์„œ์ž…๋‹ˆ๋‹ค.
* ๋ฆฌ๋“€์„œ๋Š” ์•ก์…˜์ด ์–ด๋–ป๊ฒŒ ์ƒํƒœ๋ฅผ ๋‹ค์Œ ์ƒํƒœ๋กœ ๋ณ€๊ฒฝํ•˜๋Š”์ง€ ์„œ์ˆ ํ•ฉ๋‹ˆ๋‹ค.
*
* ์ƒํƒœ์˜ ๋ชจ์–‘์€ ๋‹น์‹  ๋งˆ์Œ๋Œ€๋กœ์ž…๋‹ˆ๋‹ค: ๊ธฐ๋ณธํ˜•(primitive)์ผ์ˆ˜๋„, ๋ฐฐ์—ด์ผ์ˆ˜๋„, ๊ฐ์ฒด์ผ์ˆ˜๋„,
* ์‹ฌ์ง€์–ด Immutable.js ์ž๋ฃŒ๊ตฌ์กฐ์ผ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ค์ง ์ค‘์š”ํ•œ ์ ์€ ์ƒํƒœ ๊ฐ์ฒด๋ฅผ ๋ณ€๊ฒฝํ•ด์„œ๋Š” ์•ˆ๋˜๋ฉฐ,
* ์ƒํƒœ๊ฐ€ ๋ฐ”๋€๋‹ค๋ฉด ์ƒˆ๋กœ์šด ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
*
* ์ด ์˜ˆ์‹œ์—์„œ ์šฐ๋ฆฌ๋Š” `switch` ๊ตฌ๋ฌธ๊ณผ ๋ฌธ์ž์—ด์„ ์ผ์ง€๋งŒ,
* ์—ฌ๋Ÿฌ๋ถ„์˜ ํ”„๋กœ์ ํŠธ์— ๋งž๊ฒŒ
* (ํ•จ์ˆ˜ ๋งต ๊ฐ™์€) ๋‹ค๋ฅธ ์ปจ๋ฒค์…˜์„ ๋”ฐ๋ฅด์…”๋„ ์ข‹์Šต๋‹ˆ๋‹ค.
*/
function counter(state = 0, action) {
switch (action.type) {
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
default:
return state
}
}
โ€‹
// ์•ฑ์˜ ์ƒํƒœ๋ฅผ ๋ณด๊ด€ํ•˜๋Š” Redux ์Šคํ† ์–ด๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
// API๋กœ๋Š” { subscribe, dispatch, getState }๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
let store = createStore(counter)
โ€‹
// ์—…๋ฐ์ดํŠธ๋ฅผ ์ง์ ‘ ๊ตฌ๋…ํ•˜๊ฑฐ๋‚˜ ๋ทฐ ๋ ˆ์ด์–ด์— ๋ฐ”์ธ๋”ฉํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
// ๋ณดํ†ต์€ subscribe()๋ฅผ ์ง์ ‘ ์‚ฌ์šฉํ•˜๊ธฐ๋ณด๋‹ค๋Š” ๋ทฐ ๋ฐ”์ธ๋”ฉ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ(์˜ˆ๋ฅผ ๋“ค์–ด React Redux)๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
// ํ•˜์ง€๋งŒ ํ˜„์žฌ ์ƒํƒœ๋ฅผ localStorage์— ์˜์†์ ์œผ๋กœ ์ €์žฅํ•  ๋•Œ๋„ ํŽธ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
โ€‹
store.subscribe(() =>
console.log(store.getState())
)
โ€‹
// ๋‚ด๋ถ€ ์ƒํƒœ๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ์œ ์ผํ•œ ๋ฐฉ๋ฒ•์€ ์•ก์…˜์„ ๋ณด๋‚ด๋Š” ๊ฒƒ๋ฟ์ž…๋‹ˆ๋‹ค.
// ์•ก์…˜์€ ์ง๋ ฌํ™”๋ ์ˆ˜๋„, ๋กœ๊น…ํ• ์ˆ˜๋„, ์ €์žฅํ• ์ˆ˜๋„ ์žˆ์œผ๋ฉฐ ๋‚˜์ค‘์— ์žฌ์‹คํ–‰ํ• ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
store.dispatch({ type: 'INCREMENT' })
// 1
store.dispatch({ type: 'INCREMENT' })
// 2
store.dispatch({ type: 'DECREMENT' })
// 1

์ƒํƒœ๋ฅผ ๋ฐ”๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋Œ€์‹ , ์•ก์…˜์ด๋ผ ๋ถˆ๋ฆฌ๋Š” ํ‰๋ฒ”ํ•œ ๊ฐ์ฒด๋ฅผ ํ†ตํ•ด ์ผ์–ด๋‚  ๋ณ€๊ฒฝ์„ ๋ช…์‹œํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ฐ๊ฐ์˜ ์•ก์…˜์ด ์ „์ฒด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ƒํƒœ๋ฅผ ์–ด๋–ป๊ฒŒ ๋ณ€๊ฒฝํ• ์ง€ ๊ฒฐ์ •ํ•˜๋Š” ํŠน๋ณ„ํ•œ ํ•จ์ˆ˜์ธ ๋ฆฌ๋“€์„œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ ์—ฌ๋Ÿฌ๋ถ„์ด Flux๋ฅผ ๊ฐœ๋ฐœํ•˜๋‹ค๊ฐ€ ์™”๋‹ค๋ฉด, ์•Œ์•„๋‘ฌ์•ผ ํ•  ์ค‘์š”ํ•œ ์ฐจ์ด์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. Redux๋Š” Dispatcher๊ฐ€ ์—†๊ณ  ์Šคํ† ์–ด ์—ฌ๋Ÿฌ๊ฐœ๋ฅผ ์ง€์›ํ•˜์ง€๋„ ์•Š์Šต๋‹ˆ๋‹ค. ๋Œ€์‹  ๋ฃจํŠธ ๋ฆฌ๋“€์‹ฑ ํ•จ์ˆ˜ ํ•˜๋‚˜๋ฅผ ๊ฐ€์ง€๋Š” ๋‹จ ํ•˜๋‚˜์˜ ์Šคํ† ์–ด๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹น์‹ ์˜ ์•ฑ์ด ์ปค์ง€๋ฉด ์Šคํ† ์–ด๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๋Œ€์‹  ๋ฃจํŠธ ๋ฆฌ๋“€์„œ๋ฅผ ์ชผ๊ฐœ์„œ ์ƒํƒœ ํŠธ๋ฆฌ์˜ ๊ฐ๊ธฐ ๋‹ค๋ฅธ ๋ถ€๋ถ„์„ ๋…๋ฆฝ์ ์œผ๋กœ ๋‹ค๋ฃจ๋Š” ๋ฆฌ๋“€์„œ๋“ค์„ ๋งŒ๋“ค๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๋งˆ์น˜ React ์•ฑ์—๋Š” ํ•˜๋‚˜์˜ ๋ฃจํŠธ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์žˆ๊ณ  ์ด ๋ฃจํŠธ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ž‘์€ ์ปดํฌ๋„ŒํŠธ๋กœ ์ด๋ฃจ์–ด์ง„ ๊ฒƒ์ฒ˜๋Ÿผ์š”.

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

Learn Redux from Its Authors

Redux Video Tutorials by Dan Abramov

Getting Started with Redux

โ€‹Getting Started with Redux is a video course consisting of 30 videos narrated by Dan Abramov, author of Redux. It is designed to complement the โ€œBasicsโ€ part of the docs while bringing additional insights about immutability, testing, Redux best practices, and using Redux with React. This course is free and will always be.

โ€‹โ€œGreat course on egghead.io by @dan_abramov - instead of just showing you how to use #redux, it also shows how and why redux was built!โ€ Sandrino Di Mattia

โ€‹โ€œPlowing through @dan_abramov 'Getting Started with Redux' - its amazing how much simpler concepts get with video.โ€ Chris Dhanaraj

โ€‹โ€œThis video series on Redux by @dan_abramov on @eggheadio is spectacular!โ€ Eddie Zaneski

โ€‹โ€œCome for the name hype. Stay for the rock solid fundamentals. (Thanks, and great job @dan_abramov and @eggheadio!)โ€ Dan

โ€‹โ€œThis series of videos on Redux by @dan_abramov is repeatedly blowing my mind - gunna do some serious refactoringโ€ Laurence Roberts

So, what are you waiting for?

Note: If you enjoyed Dan's course, consider supporting Egghead by buying a subscription. Subscribers have access to the source code of every example in my videos and tons of advanced lessons on other topics, including JavaScript in depth, React, Angular, and more. Many Egghead instructors are also open source library authors, so buying a subscription is a nice way to thank them for the work that they've done.

Building React Applications with Idiomatic Redux

The Building React Applications with Idiomatic Redux course is a second free video series by Dan Abramov. It picks up where the first series left off, and covers practical production ready techniques for building your React and Redux applications: advanced state management, middleware, React Router integration, and other common problems you are likely to encounter while building applications for your clients and customers. As with the first series, this course will always be free.

Practical Redux course

โ€‹Practical Redux is a paid interactive course by Redux co-maintainer Mark Erikson. The course is designed to show how to apply the basic concepts of Redux to building something larger than a TodoMVC application. It includes real-world topics like:

  • Adding Redux to a new Create-React-App project and configuring Hot Module Replacement for faster development

  • Controling your UI behavior with Redux

  • Using the Redux-ORM library to manage relational data in your Redux store

  • Building a master/detail view to display and edit data

  • Writing custom advanced Redux reducer logic to solve specific problems

  • Optimizing performance of Redux-connected form inputs

And much more!

The course is based on Mark's original free "Practical Redux" blog tutorial series, but with updated and improved content.

Redux Fundamentals Workshop

Redux co-maintainer Mark Erikson has put together a Redux Fundamentals workshop, and slides are available here. They cover:

  • The history and purpose of Redux

  • Reducers, actions, and working with a Redux store

  • Using Redux with React

  • Using and writing Redux middleware

  • Working with AJAX calls and other side effects

  • Unit testing Redux apps

  • Real-world Redux app structure and development

๋ฌธ์„œ

์˜คํ”„๋ผ์ธ์—์„œ ์ฝ๊ธฐ ์œ„ํ•œ PDF, ePub, MOBI ๋ฒ„์ „์„ ๋ฐ›๊ฑฐ๋‚˜ ์–ด๋–ป๊ฒŒ ๋งŒ๋“œ๋Š”์ง€ ์•Œ๊ณ  ์‹ถ๋‹ค๋ฉด, paulkogel/redux-offline-docs์„ ๋ณด์„ธ์š”.

Offline ๋ฌธ์„œ๋Š” devdocs์„ ๋ณด์„ธ์š”.

์˜ˆ์‹œ

Almost all examples have a corresponding CodeSandbox sandbox. This is an interactive version of the code that you can play with online.

๋งŒ์•ฝ ์—ฌ๋Ÿฌ๋ถ„์ด NPM ์ƒํƒœ๊ณ„๊ฐ€ ์ƒ์†Œํ•˜๊ณ  ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•˜๋Š”๋ฐ ๋ฌธ์ œ๊ฐ€ ์žˆ๊ฑฐ๋‚˜ ์œ„์˜ ์ฝ”๋“œ๋ฅผ ์–ด๋””์— ๋ถ™์—ฌ๋„ฃ์–ด์•ผ ํ• ์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค๋ฉด, Redux๋ฅผ React์™€ Browserify์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” simplest-redux-example์„ ์ฐธ๊ณ ํ•˜์„ธ์š”.

์ถ”์ฒœ์‚ฌ

โ€‹"Love what youโ€™re doing with Redux" Jing Chen, creator of Flux

โ€‹"I asked for comments on Redux in FB's internal JS discussion group, and it was universally praised. Really awesome work." Bill Fisher, creator of Flux

โ€‹"It's cool that you are inventing a better Flux by not doing Flux at all." Andrรฉ Staltz, creator of Cycle

๊ฐ์‚ฌ์˜ ๋ง

  • โ€‹The Elm Architecture for a great intro to modeling state updates with reducers;

  • โ€‹Turning the database inside-out for blowing my mind;

  • โ€‹Developing ClojureScript with Figwheel for convincing me that re-evaluation should "just work";

  • โ€‹Webpack for Hot Module Replacement;

  • โ€‹Flummox for teaching me to approach Flux without boilerplate or singletons;

  • โ€‹disto for a proof of concept of hot reloadable Stores;

  • โ€‹NuclearJS for proving this architecture can be performant;

  • โ€‹Om for popularizing the idea of a single state atom;

  • โ€‹Cycle for showing how often a function is the best tool;

  • โ€‹React for the pragmatic innovation.

NPM ํŒจํ‚ค์ง€๋ช…์ธ redux๋ฅผ ๋„˜๊ฒจ์ฃผ์‹  Jamie Paton์—๊ฒŒ ํŠน๋ณ„ํ•œ ๊ฐ์‚ฌ์˜ ๋ง์„ ์ „ํ•ฉ๋‹ˆ๋‹ค.

๋กœ๊ณ 

๊ณต์‹ ๋กœ๊ณ ๋ฅผ GitHub์—์„œ ์ฐพ์•„๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ณ€๊ฒฝ ๊ธฐ๋ก

์ด ํ”„๋กœ์ ํŠธ๋Š” ์œ ์˜์  ๋ฒ„์ „์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค. ๋งค ๋ฆด๋ฆฌ์ฆˆ๋Š” ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ์„ค๋ช…๊ณผ ํ•จ๊ป˜ ๊นƒํ—™ ๋ฆด๋ฆฌ์ฆˆ ํŽ˜์ด์ง€์— ๋ฌธ์„œํ™”๋ฉ๋‹ˆ๋‹ค.

ํ›„์›์ž

Redux ์ž‘์—…์€ ์ปค๋ฎค๋‹ˆํ‹ฐ์— ์˜ํ•ด ํŽ€๋”ฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ–ˆ๋˜ ์ฃผ์š”ํ•œ ํšŒ์‚ฌ๋“ค์„ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค.

โ€‹์ „์ฒด ํ›„์›์ž ๋ช…๋‹จ๊ณผ ์ง€์†์ ์œผ๋กœ ๋Š˜์–ด๋‚˜๊ณ  ์žˆ๋Š” Redux๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ๋žŒ๊ณผ ํšŒ์‚ฌ๋“ค ๋ชฉ๋ก์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ผ์ด์„ ์Šค

MIT

๋ฒˆ์—ญ

ํ•œ๊ตญ์–ด ๋ฒˆ์—ญ ๊ธฐ์—ฌ๋Š” Github ์ €์žฅ์†Œ๋กœ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋ณด๋‚ด์ฃผ์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.