{"id":267133,"date":"2015-10-30T10:54:02","date_gmt":"2015-10-30T07:54:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=267133"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=267133","title":{"rendered":"\u0421 0 \u0434\u043e 1. \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441 Redux"},"content":{"rendered":"<p>       \u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0448\u043b\u0430 \u0432\u0435\u0440\u0441\u0438\u044f 1.0 Redux, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0441\u0435\u0440\u0438\u044e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u043e\u0432 \u043e \u043c\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u201c\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e Flux\u201d \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 Redux.<\/p>\n<h4>\u041f\u043e\u0447\u0435\u043c\u0443 Redux?<\/h4>\n<p>  Redux \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0441\u0435\u0431\u044f \u043a\u0430\u043a \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (state) \u0434\u043b\u044f JavaScript \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0420\u0435\u0434\u0430\u043a\u0441 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d <a href=\"https:\/\/facebook.github.io\/flux\/\">Flux<\/a> \u0438 <a href=\"http:\/\/elm-lang.org\/\">Elm<\/a>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 Flux, \u044f \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e Redux \u0438\u043c\u0435\u0435\u0442 \u0441 \u043d\u0438\u043c \u043e\u0431\u0449\u0435\u0433\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 &quot;<a href=\"https:\/\/github.com\/rajdee\/redux-in-russian\/blob\/master\/docs\/introduction\/PriorArt.mdhttp:\/\/\">\u041f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0438<\/a>&quot; \u043d\u043e\u0432\u043e\u0439 (\u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0439!) \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>  Redux \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043a\u0430\u043a \u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 (actions), \u0447\u0442\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e Redux, \u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0438 \u0440\u043e\u043b\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <a href=\"https:\/\/github.com\/rajdee\/redux-in-russian\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439 \u0441 React \u0438 Redux<\/h2>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0420\u0435\u0434\u0430\u043a\u0441 \u0438 \u0420\u0435\u0430\u043a\u0442: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439 \u0441 \u043d\u0443\u043b\u044f.<\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/jchapron\/redux-friendlist-demo\/tree\/v1.0\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/www.jchapron.com\/content\/images\/2015\/08\/thefriendlist.gif\" alt=\"image\"\/><\/p>\n<h4>\u0414\u043b\u044f \u043a\u043e\u0433\u043e?<\/h4>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439, \u043d\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Redux. \u041e\u043f\u044b\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441 Flux \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u0435\u043d. \u042f \u0431\u0443\u0434\u0443 \u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u043c\u0438.<\/p>\n<h5>1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h5>\n<p>  \u0410\u0432\u0442\u043e\u0440 Redux, \u0414\u0430\u043d\u0438\u0438\u043b \u0410\u0431\u0440\u0430\u043c\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043b \u043e\u0442\u043b\u0438\u0447\u043d\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441 React, Webpack, ES6\/7 \u0438 React Hot Loader, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/gaearon\/react-hot-boilerplate\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 \u0443\u0436\u0435 \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c Redux, \u043d\u043e, \u044f \u0434\u0443\u043c\u0430\u044e, \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0440\u043e\u043b\u044c \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<pre><code class=\"javascript\">$ git clone https:\/\/github.com\/gaearon\/react-hot-boilerplate.git friendlist $ cd friendlist && npm install $ npm start <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:3000\">http:\/\/localhost:3000<\/a>. \u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u00abhello world\u00bb \u0433\u043e\u0442\u043e\u0432!<\/p>\n<h5>1.1 \u0414\u043e\u0431\u0430\u0432\u0438\u043c redux, react-redux \u0438 redux-devtools<\/h5>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0440\u0438 \u043f\u0430\u043a\u0435\u0442\u0430:<\/p>\n<ul>\n<li>Redux: \u0441\u0430\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/li>\n<li>React-redux: \u0441\u0432\u044f\u0437\u043a\u0430 \u0441 React<\/li>\n<li>Redux-devtools: \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e, \u0434\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">$ npm install --save redux@1.0.0-rc react-redux $ npm install --save-dev redux-devtools <\/code><\/pre>\n<p>  <\/p>\n<h5>1.2 \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439<\/h5>\n<p>  \u0425\u043e\u0442\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u043a\u0430\u043a \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"javascript\">+-- src |   +-- actions |       +-- index.js |   +-- components |       +-- index.js |   +-- constants |       +-- ActionTypes.js |   +-- containers |       +-- App.js |       +-- FriendListApp.js |   +-- reducers |       +-- index.js |       +-- friendlist.js |   +-- utils |   +-- index.js +-- index.html +-- app.css <\/code><\/pre>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0440\u043e\u043b\u044c \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043b\u0438 App.js \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e containers, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442 statement \u0432 index.js.<\/p>\n<h5>1.3 \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c Redux<\/h5>\n<p>  <b>\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c devtools<\/b><\/p>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c devtools \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c webpack.config.js \u043a\u0430\u043a \u0437\u0434\u0435\u0441\u044c:<\/p>\n<pre><code class=\"javascript\">\/* webpack.config.js *\/  var devFlagPlugin = new webpack.DefinePlugin({   __DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false')) });  [...]  plugins: [     new webpack.HotModuleReplacementPlugin(),     new webpack.NoErrorsPlugin(),     devFlagPlugin ] <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 <code>DEBUG=true npm start<\/code>, \u044d\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442 <code>__DEV__<\/code> \u0444\u043b\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c devtools \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">\/* src\/utils\/devTools.js *\/  import React from 'react'; import { createStore as initialCreateStore, compose } from 'redux';  export let createStore = initialCreateStore;  if (__DEV__) {   createStore = compose(     require('redux-devtools').devTools(),     require('redux-devtools').persistState(       window.location.href.match(\/[?&]debug_session=([^&]+)\\b\/)     ),     createStore   ); }  export function renderDevTools(store) {   if (__DEV__) {     let {DevTools, DebugPanel, LogMonitor} = require('redux-devtools\/lib\/react');     return (       &lt;DebugPanel top right bottom&gt;         &lt;DevTools store={store} monitor={LogMonitor} \/&gt;       &lt;\/DebugPanel&gt;     );   }   return null; } <\/code><\/pre>\n<p>  \u041c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u0434\u0432\u0435 \u0432\u0435\u0449\u0438. \u041c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c createStore \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 <a href=\"https:\/\/github.com\/rajdee\/redux-in-russian\/blob\/master\/docs\/Glossary.md\">store enhancers<\/a>, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a devTools. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e renderDevTools, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 DebugPanel.<\/p>\n<p>  <b>\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/b><\/p>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c App.js \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 redux. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Provider<\/code> \u0438\u0437 react-redux. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0430\u0448 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0432 Provider \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u0441\u044f \u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0435\u0435 \u0446\u0435\u043b\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u201c\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u201d \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0420\u0435\u0430\u043a\u0442\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0434\u0435\u0442\u0435\u0439 (\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432).<\/p>\n<pre><code class=\"javascript\">\/* src\/containers\/App.js *\/  import React, { Component } from 'react'; import { combineReducers } from 'redux'; import { Provider } from 'react-redux';  import { createStore, renderDevTools } from '..\/utils\/devTools';  import FriendListApp from '.\/FriendListApp'; import * as reducers from '..\/reducers';  const reducer = combineReducers(reducers); const store = createStore(reducer); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>createStore<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432 devTools \u0444\u0430\u0439\u043b\u0435, \u043a\u0430\u043a map \u0432\u0441\u0435\u0445 \u043d\u0430\u0448\u0438\u0445 \u0440\u0435\u0434\u044c\u044e\u0441\u0435\u0440\u043e\u0432.<\/p>\n<p>  ES6 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <code>import * as reducers<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0432\u0438\u0434\u0435 { key: fn(state, action),\u2026 }. \u042d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f <code>combineReducers<\/code>.<\/p>\n<pre><code class=\"javascript\">export default class App extends Component {   render() {     return (       &lt;div&gt;         &lt;Provider store={store}&gt;           {() =&gt; &lt;FriendListApp \/&gt; }         &lt;\/Provider&gt;          {renderDevTools(store)}       &lt;\/div&gt;     );   } } <\/code><\/pre>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 App.js \u2014 \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043b\u044f Redux \u0438 FriendListApp \u2014 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u2018Hello world\u2019 \u0432 FriendListApp.js, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 redux \u0438 devTools. \u0412\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u043e (\u0431\u0435\u0437 \u0441\u0442\u0438\u043b\u0435\u0439).<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/www.jchapron.com\/content\/images\/2015\/08\/Screen-Shot-2015-08-14-at-15-33-31.png\" alt=\"image\"\/><\/p>\n<p>  \u0425\u043e\u0442\u044f \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2018Hello world\u2019 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0443 \u043d\u0430\u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d Hot Reloading, \u0442.\u0435. \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, devtools \u0441\u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430. \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u0445!<\/p>\n<h5>2. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0441\u0434\u0435\u043b\u0430\u043d\u044b \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<h5>2.1 \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/h5>\n<p>  <a href=\"https:\/\/github.com\/rajdee\/redux-in-russian\/blob\/master\/docs\/basics\/Actions.mdhttp:\/\/\">\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/a> \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u041f\u043e \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044e, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 <code>type<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u0438\u043f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u0442\u0438\u043f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u200a \u2014 \u200a\u0445\u043e\u0440\u043e\u0448\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430, \u0438 \u044d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">\/* src\/constants\/ActionTypes.js *\/  export const ADD_FRIEND = 'ADD_FRIEND'; export const STAR_FRIEND = 'STAR_FRIEND'; export const DELETE_FRIEND = 'DELETE_FRIEND'; <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442\u044c \u043d\u0430\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0440\u0443\u0437\u0435\u0439, \u043e\u0442\u043c\u0435\u0447\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u00ab\u0438\u0437\u0431\u0440\u0430\u043d\u043d\u044b\u0445\u00bb \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438\u0445 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>  <a href=\"https:\/\/github.com\/rajdee\/redux-in-russian\/blob\/master\/docs\/basics\/Actions.md\">\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/a> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0412 Redux \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0438\u0441\u0442\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u043f\u043e\u0440\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442.\u043a. \u043e\u043d\u0438 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0441\u0430\u0439\u0434-\u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>  \u041c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0438\u0445 \u0432 \u043f\u0430\u043f\u043a\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f.<\/p>\n<pre><code class=\"javascript\">\/* src\/actions\/FriendsActions.js *\/  import * as types from '..\/constants\/ActionTypes';  export function addFriend(name) {   return {     type: types.ADD_FRIEND,     name   }; }  export function deleteFriend(id) {   return {     type: types.DELETE_FRIEND,     id   }; }  export function starFriend(id) {   return {     type: types.STAR_FRIEND,     id   }; } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b. \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043c\u044b \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (\u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 name), \u0430 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u044b \u0441\u0441\u044b\u043b\u0430\u0435\u043c\u0441\u044f \u043d\u0430 id. \u0412 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043c\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438\u043c\u0435\u043b\u0438 \u0431\u044b \u0434\u0435\u043b\u043e \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438, \u043d\u043e \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438\u2026<\/p>\n<h5>2.2 \u0420\u0435\u0434\u044c\u044e\u0441\u0435\u0440\u044b<\/h5>\n<p>  <a href=\"https:\/\/github.com\/rajdee\/redux-in-russian\/blob\/master\/docs\/basics\/Reducers.md\">\u0420\u0435\u0434\u044c\u044e\u0441\u0435\u0440\u044b<\/a> \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041e\u043d\u0438 \u2014 \u0447\u0438\u0441\u0442\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0432\u0438\u0434\u043e\u043c <code>(previousState, action) =&gt; newState<\/code>. \u041e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b <b>\u043d\u0438\u043a\u043e\u0433\u0434\u0430<\/b> (\u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430) \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u0440\u0435\u0434\u044c\u044e\u0441\u0435\u0440\u0435. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u0431\u0430\u0437\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 previousState. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f. \u0422\u0430\u043a\u0436\u0435, \u044d\u0442\u043e \u043d\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0430\u0439\u0434-\u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u0438\u043b\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b.<\/p>\n<p>  \u041c\u044b, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0432\u0438\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 <code>initialState<\/code>:<\/p>\n<pre><code class=\"javascript\">\/* src\/reducers\/friends.js *\/  const initialState = {   friends: [1, 2, 3],   friendsById: {     1: {       id: 1,       name: 'Theodore Roosevelt'     },     2: {       id: 2,       name: 'Abraham Lincoln'     },     3: {       id: 3,       name: 'George Washington'     }   } }; <\/code><\/pre>\n<p>  \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0440\u0443\u0437\u0435\u0439. \u041d\u043e \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043b\u043e\u0445\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 id \u0438 map \u0434\u0440\u0443\u0437\u0435\u0439. \u041e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/gaearon\/normalizr\">normalizr<\/a>.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0434\u044c\u044e\u0441\u0435\u0440. \u041c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 ES6 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0434\u044c\u044e\u0441\u0435\u0440, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e switch.<\/p>\n<pre><code class=\"javascript\">export default function friends(state = initialState, action) {   switch (action.type) {      case types.ADD_FRIEND:       const newId = state.friends[state.friends.length-1] + 1;       return {         friends: state.friends.concat(newId),         friendsById: {           ...state.friendsById,           [newId]: {             id: newId,             name: action.name           }         }       }      default:       return state;   } } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c ES6\/7, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0443\u0434\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c. \u0422.\u043a. \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <a href=\"https:\/\/developer.mozilla.org\/en\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Object\/assign\">Object.assign<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/Spread_operator\">Spread operator<\/a>.<\/p>\n<p>  \u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442: \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 id. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0435\u0433\u043e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u043b\u0438, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>concat<\/code> \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043d\u043e\u0432\u044b\u0439 id \u0432 \u043d\u0430\u0448 id-\u043b\u0438\u0441\u0442. Concat \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439.<\/p>\n<p>  <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/Object_initializer#Computed_property_names\">Computed properties<\/a> \u200a\u2014 \u200a\u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 ES6, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0449\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 key \u0432 friendsById \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0441 <code>[newId]<\/code>.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043c\u0443\u0442\u0438\u0442\u044c, \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430. \u0412\u044b \u0437\u0430\u0434\u0430\u0435\u0442\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u043d\u0430\u0437\u0430\u0434 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0412\u0430\u0436\u043d\u043e: \u043d\u0438 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>  \u041e\u043a\u0435\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0440\u0435\u0434\u044c\u044e\u0441\u0435\u0440\u044b \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439:<\/p>\n<pre><code class=\"javascript\">import omit from 'lodash\/object\/omit'; import assign from 'lodash\/object\/assign'; import mapValues from 'lodash\/object\/mapValues';  \/* ... *\/  case types.DELETE_FRIEND:       return {         ...state,         friends: state.friends.filter(id =&gt; id !== action.id),         friendsById: omit(state.friendsById, action.id)       }      case types.STAR_FRIEND:       return {         ...state,         friendsById: mapValues(state.friendsById, (friend) =&gt; {           return friend.id === action.id ?             assign({}, friend, { starred: !friend.starred }) :             friend         })       } <\/code><\/pre>\n<p>  \u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b lodash, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0432 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0432\u043c\u0435\u0441\u0442\u043e <code>delete state.friendsById[action.id]<\/code>, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>_.omit<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>  \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e spread \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043c\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c.<\/p>\n<p>  Redux \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u043a\u0430\u043a \u0432\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/facebook.github.io\/immutable-js\/\">Immutable.js<\/a>.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u043c\u0438\u043d\u0443\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u0443\u0442\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0430 dispatch \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0432 \u043d\u0430\u0448\u0435\u043c App.js.<\/p>\n<pre><code class=\"javascript\">\/* src\/containers\/App.js *\/  import { addFriend, deleteFriend, starFriend } from '..\/actions\/FriendsActions';  store.dispatch(addFriend('Barack Obama'));  store.dispatch(deleteFriend(1));  store.dispatch(starFriend(4)); <\/code><\/pre>\n<p>  \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 devTools \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0441 \u043d\u0438\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/www.jchapron.com\/content\/images\/2015\/08\/Screen-Shot-2015-08-14-at-15-31-07.png\" alt=\"image\"\/><\/p>\n<h5>3. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/h5>\n<p>  \u0422.\u043a. \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u043d\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c, \u044f \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 React-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 Redax. \u041c\u044b \u0438\u043c\u0435\u0435\u043c \u0442\u0440\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430:<\/p>\n<ul>\n<li><b>FriendList<\/b> \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439 <code>&lt;ul&gt;<\/code><br \/> \n<ul>\n<li><code>friends: array<\/code> \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0440\u0443\u0437\u0435\u0439   <\/li>\n<\/ul>\n<p>   <\/li>\n<li><b>FriendListItem<\/b> \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0430 <code>&lt;li&gt;<\/code><br \/> \n<ul>\n<li><code>name: string<\/code> \u0438\u043c\u044f \u0434\u0440\u0443\u0433\u0430 <\/li>\n<li><code>starred: boolean<\/code> \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0443, \u0435\u0441\u043b\u0438 \u0434\u0440\u0443\u0433 \u043e\u0442\u043c\u0435\u0447\u0435\u043d, \u043a\u0430\u043a \u0438\u0437\u0431\u0440\u0430\u043d\u043d\u044b\u0439 <\/li>\n<li><code>starFriend: function<\/code> \u0432\u044b\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0438<\/li>\n<li><code>deleteFriend: function<\/code> \u0432\u044b\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u043a\u043e\u0440\u0437\u0438\u043d\u0443<\/li>\n<\/ul>\n<p>   <\/li>\n<li><b>AddFriendInput<\/b> \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u043d\u043e\u0432\u044b\u0445 \u0438\u043c\u0451\u043d<br \/> \n<ul>\n<li><code>addFriend: function<\/code> \u0432\u044b\u0437\u043e\u0432, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u0432\u0432\u043e\u0434<\/li>\n<\/ul>\n<p>   <\/li>\n<\/ul>\n<p>  \u0412 Redux \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u201c\u0433\u043b\u0443\u043f\u044b\u043c\u0438\u201d. \u0422.\u0435. \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 Redux, \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435.<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c <b>FriendListApp<\/b> \u0431\u0443\u0434\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u201c\u0443\u043c\u043d\u044b\u043c\u201d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c.<\/p>\n<pre><code class=\"javascript\">import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import * as FriendsActions from '..\/actions\/FriendsActions'; import { FriendList, AddFriendInput } from '..\/components';  @connect(state =&gt; ({   friendlist: state.friendlist })) export default class FriendListApp extends Component { <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 ES6, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430. \u0411\u0443\u0434\u0435\u0442 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u0430 <code>connect(select)(FriendListApp);<\/code> \u0433\u0434\u0435 <code>select<\/code> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">static propTypes = {     friendsById: PropTypes.object.isRequired,     dispatch: PropTypes.func.isRequired   }    render () {     const { friendlist: { friendsById }, dispatch } = this.props;     const actions = bindActionCreators(FriendsActions, dispatch);      return (       &lt;div className={styles.friendListApp}&gt;         &lt;h1&gt;The FriendList&lt;\/h1&gt;         &lt;AddFriendInput addFriend={actions.addFriend} \/&gt;         &lt;FriendList friends={friendsById} actions={actions} \/&gt;       &lt;\/div&gt;     );   } } <\/code><\/pre>\n<p>  \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>bindActionCreators<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430\u0448\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432\u044b\u0437\u043e\u0432\u043e\u043c dispatch. \u0426\u0435\u043b\u044c \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u0430\u0448\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f dispatch \u043e\u0431\u044a\u0435\u043a\u0442\u0430 (\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0438\u0445 \u0433\u043b\u0443\u043f\u044b\u043c\u0438).<\/p>\n<p>  \u0422\u043e, \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f React. \u041c\u044b \u043f\u0440\u0438\u0432\u044f\u0436\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a onClick, onChange \u0438\u043b\u0438 onKeyDown \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/jchapron\/redux-friendlist-demo\/blob\/v1.0\/src\/components\/AddFriendInput.js\">\u0432\u0435\u0441\u044c \u043a\u043e\u0434<\/a>.<\/p>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0443\u0432\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0433\u0438\u044e \u0440\u0430\u0431\u043e\u0442\u044b redux\/react \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041a\u0430\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e \u043d\u0430 GIF, \u0432\u044b \u043b\u043e\u0433\u0433\u0438\u0440\u0443\u0435\u0442\u0435 \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<br \/>  \u0420\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u0442\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0431\u0430\u0433\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f, \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0443\u0436\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u2026       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/269831\/\"> http:\/\/habrahabr.ru\/post\/269831\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0448\u043b\u0430 \u0432\u0435\u0440\u0441\u0438\u044f 1.0 Redux, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0441\u0435\u0440\u0438\u044e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u043e\u0432 \u043e \u043c\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u201c\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e Flux\u201d \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 Redux.<\/p>\n<h4>\u041f\u043e\u0447\u0435\u043c\u0443 Redux?<\/h4>\n<p>  Redux \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0441\u0435\u0431\u044f \u043a\u0430\u043a \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (state) \u0434\u043b\u044f JavaScript \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0420\u0435\u0434\u0430\u043a\u0441 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d <a href=\"https:\/\/facebook.github.io\/flux\/\">Flux<\/a> \u0438 <a href=\"http:\/\/elm-lang.org\/\">Elm<\/a>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 Flux, \u044f \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e Redux \u0438\u043c\u0435\u0435\u0442 \u0441 \u043d\u0438\u043c \u043e\u0431\u0449\u0435\u0433\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 &quot;<a href=\"https:\/\/github.com\/rajdee\/redux-in-russian\/blob\/master\/docs\/introduction\/PriorArt.mdhttp:\/\/\">\u041f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0438<\/a>&quot; \u043d\u043e\u0432\u043e\u0439 (\u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0439!) \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>  Redux \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043a\u0430\u043a \u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 (actions), \u0447\u0442\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-267133","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/267133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267133"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/267133\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}