{"id":263369,"date":"2015-08-12T04:48:34","date_gmt":"2015-08-12T00:48:34","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=263369"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=263369","title":{"rendered":"\u0418\u0437\u043e\u043c\u043e\u0440\u0444\u043d\u043e\u0435 \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 React \u0438 Redux"},"content":{"rendered":"<p>       \u0418\u0442\u0430\u043a, \u044f \u0437\u043d\u0430\u044e \u0447\u0442\u043e \u0442\u044b \u043b\u044e\u0431\u0438\u0448\u044c Todo \u0441\u043f\u0438\u0441\u043a\u0438, \u0442\u043e \u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u0431\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c Todo \u0441\u043f\u0438\u0441\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0442\u044b \u0441\u043e\u0437\u0434\u0430\u043b \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u043e\u0432\u044b\u0439, \u0432\u043e\u0441\u0445\u0438\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438 \u043f\u0438\u0442\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 <i>(\u00abnutritious\u00bb \u043f\u0440\u0438\u043c. \u043f\u0435\u0440.)<\/i> Flux \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, <a href=\"https:\/\/github.com\/gaearon\/redux\">Redux<\/a>! \u042f \u0436\u0435\u043b\u0430\u044e \u0442\u0435\u0431\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0443\u0447\u0448\u0435\u0433\u043e.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0442\u044b \u043d\u0430\u0443\u0447\u0438\u0448\u044c\u0441\u044f \u043a\u0430\u043a \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 Redux \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044f\u0441\u044c, \u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f.<\/p>\n<ul>\n<li>\u0426\u0435\u043b\u044c\u043d\u043e\u0437\u0435\u0440\u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435<\/li>\n<li>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 \u0440\u043e\u0443\u0442\u0438\u043d\u0433, \u0431\u043e\u0433\u0430\u0442\u044b\u0439 Omega-3<\/li>\n<li>\u041c\u0430\u0441\u043b\u044f\u043d\u0438\u0441\u0442\u0430\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li>\u0413\u043b\u0430\u0434\u043a\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0441\u043b\u0435\u0432\u043a\u0443\u0441\u0438\u0435<\/li>\n<\/ul>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0435\u0433\u043e \u0442\u044b \u0445\u043e\u0447\u0435\u0448\u044c \u0432 \u044d\u0442\u043e\u0439 \u0436\u0438\u0437\u043d\u0438, \u0432\u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0434 \u043a\u0430\u0442, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0439\u0441\u044f.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0425\u043e\u0447\u0443 \u0442\u0435\u0431\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c\u2026 \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0441\u0443\u043f\u0435\u0440 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0438\u0441\u0442\u0435\u0433\u043d\u0438\u0441\u044c \u0438 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u044c\u0441\u044f \u043a \u0442\u0435\u0440\u043d\u0438\u0441\u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u043d\u0435 \u0432\u044b\u0441\u043e\u0432\u044b\u0432\u0430\u0439 \u0440\u0443\u043a\u0438 \u0438 \u043d\u043e\u0433\u0438 \u0438 \u0432\u0441\u0435 \u0442\u0430\u043a\u043e\u0435\u2026<\/p>\n<h4><b>\u0421\u0442\u043e\u043f, \u043f\u043e\u0434\u043e\u0436\u0434\u0438, \u0430 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Redux?<\/b><\/h4>\n<p>  \u041e\u0445, \u044f \u0440\u0430\u0434 \u0447\u0442\u043e \u0442\u044b \u0441\u043f\u0440\u043e\u0441\u0438\u043b!<\/p>\n<p>  <a href=\"https:\/\/github.com\/gaearon\/redux\"><b>Redux<\/b><\/a> \u044d\u0442\u043e \u043d\u043e\u0432\u044b\u0439 Flux \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043e\u0442 <a href=\"https:\/\/github.com\/gaearon\">\u0414\u0430\u043d\u0438\u043b\u0430 \u0410\u0431\u0440\u0430\u043c\u043e\u0432\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u0422\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d <a href=\"https:\/\/medium.com\/@dan_abramov\/the-evolution-of-flux-frameworks-6c16ad26bb31\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/www.youtube.com\/watch?v=xsSnOQynTHs\">\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a>, \u0432 \u043e\u0431\u0449\u0435\u043c TL: DR <b>Redux<\/b> \u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0442\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u044d\u0442\u0438\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c <i>(state \u043e\u0440\u0438\u0433.)<\/i>.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0442\u044b \u0437\u043d\u0430\u043a\u043e\u043c \u0441 <a href=\"https:\/\/facebook.github.io\/flux\/docs\/overview.html\">\u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438<\/a> <a href=\"http:\/\/acdlite.github.io\/flummox\">Flux<\/a> <a href=\"http:\/\/martyjs.org\/\">\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438<\/a>, \u0442\u043e\u0433\u0434\u0430 \u0441\u0430\u043c\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0448\u044c, \u044d\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449 <i>(Stores \u043e\u0440\u0438\u0433.)<\/i>, \u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u00ab\u0420\u0435\u0434\u044e\u0441\u0435\u0440\u043e\u0432\u00bb <i>(Reducers \u043e\u0440\u0438\u0433.)<\/i>.<br \/>  \u0412 <b>Reflux<\/b>, \u0432\u0441\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0436\u0438\u0432\u0435\u0442 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 (\u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Redux), \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u0438\u0442\u0441\u044f \u0438\u0437\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0443).<br \/>  \u00ab\u0420\u0435\u0434\u044e\u0441\u0435\u0440\u00bb \u2014 \u044d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f, \u043e\u043d \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u043e \u0441\u0443\u0442\u0438, \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"javascript\">function exampleReducer(state, action) {   return state.changedBasedOn(action) } <\/code><\/pre>\n<p>  \u041a\u0430\u043a? \u0422\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0448\u044c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  \u0422\u044b \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0434\u0443\u043c\u0430\u0435\u0448\u044c \u0447\u0442\u043e <b>Redux<\/b> \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0447\u0435\u043c \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a. \u042d\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0431\u0430\u0437\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u043b\u0443\u0447\u0448\u0438\u0435 \u0438\u0434\u0435\u0438 Flux. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043d\u0430\u0443\u0447\u0438\u0442 \u0442\u0435\u0431\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043f\u0440\u043e\u0446\u0432\u0435\u0442\u0430\u0442\u044c \u0438 \u0438\u0434\u0442\u0438 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u0443\u0442\u0430\u0446\u0438\u044f\u043c\u0438.<\/p>\n<h4><b>\u0414\u0435\u043b\u0430\u0435\u043c \u0441\u0435\u0431\u0435 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e<\/b><\/h4>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/webpack.github.io\/\">Webpack<\/a> \u0438 <a href=\"http:\/\/www.babel.com\/\">Babel<\/a>, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0435, \u0443\u043c\u043d\u044b\u0435 \u0438 \u0440\u0430\u0434\u043e\u0441\u0442\u043d\u044b\u0435, \u0438 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u0434\u0430\u044e\u0442 \u043d\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <a href=\"https:\/\/gaearon.github.io\/react-hot-loader\/\">\u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430\u043b\u0435\u0442\u0443<\/a> \u0438 \u0441\u0430\u043c\u044b\u0435 \u0441\u0432\u0435\u0436\u0438\u0435 ES6\/7 \u0444\u0438\u0448\u043a\u0438.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>  \u0412\u043e\u0442 <i><b>package.json<\/b><\/i> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u043b:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">package.json<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">{   &quot;name&quot;: &quot;isomorphic-redux&quot;,   &quot;version&quot;: &quot;1.0.0&quot;,   &quot;description&quot;: &quot;Basic isomorphic redux application&quot;,   &quot;main&quot;: &quot;index.js&quot;,   &quot;scripts&quot;: {     &quot;start&quot;: &quot;NODE_PATH=$NODE_PATH:.\/shared node .&quot;,     &quot;dev&quot;: &quot;npm run start & webpack-dev-server --progress --color&quot;   },   &quot;author&quot;: &quot;&lt;your-name&gt; &lt;&lt;your-email&gt;&gt;&quot;,   &quot;license&quot;: &quot;MIT&quot;,   &quot;dependencies&quot;: {     &quot;axios&quot;: &quot;^0.5.4&quot;,     &quot;express&quot;: &quot;^4.13.2&quot;,     &quot;immutable&quot;: &quot;^3.7.4&quot;,     &quot;object-assign&quot;: &quot;^3.0.0&quot;,     &quot;react&quot;: &quot;^0.13.3&quot;,     &quot;react-redux&quot;: &quot;^0.2.2&quot;,     &quot;react-router&quot;: &quot;^1.0.0-beta3&quot;,     &quot;redux&quot;: &quot;^1.0.0-rc&quot;   },   &quot;devDependencies&quot;: {     &quot;babel&quot;: &quot;^5.8.20&quot;,     &quot;babel-eslint&quot;: &quot;^4.0.5&quot;,     &quot;babel-loader&quot;: &quot;^5.3.2&quot;,     &quot;eslint&quot;: &quot;^1.0.0&quot;,     &quot;eslint-plugin-react&quot;: &quot;^3.1.0&quot;,     &quot;react-hot-loader&quot;: &quot;^1.2.8&quot;,     &quot;webpack&quot;: &quot;^1.10.5&quot;,     &quot;webpack-dev-server&quot;: &quot;^1.10.1&quot;   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0430 \u0442\u0430\u043a\u0436\u0435  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">webpack.config.js<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">var path    = require('path'); var webpack = require('webpack');  module.exports = {   entry:  [     'webpack-dev-server\/client?http:\/\/localhost:8080\/',     'webpack\/hot\/only-dev-server',     '.\/client'   ],   output: {     path:     path.join(__dirname, 'dist'),     filename: 'bundle.js'   },   resolve: {     modulesDirectories: ['node_modules', 'shared'],     extensions:        ['', '.js', '.jsx']   },   module: {     loaders: [       {         test:    \/\\.jsx?$\/,         exclude: \/node_modules\/,         loaders: ['react-hot', 'babel']       }     ]   },   plugins: [     new webpack.HotModuleReplacementPlugin(),     new webpack.NoErrorsPlugin()   ],   devtool: 'inline-source-map',   devServer: {     hot: true,     proxy: {       '*': 'http:\/\/localhost:' + (process.env.PORT || 3000)     }   } }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0438 <i><b>.babelrc<\/b><\/i> (\u0434\u043b\u044f &#8216;ES7&#8217; \u0441\u0430\u0445\u0430\u0440\u043a\u0430)  <\/p>\n<pre><code class=\"javascript\">{   &quot;optional&quot;: [&quot;es7.decorators&quot;, &quot;es7.classProperties&quot;, &quot;es7.objectRestSpread&quot;] } <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0437\u043d\u0430\u0442\u044c\u0441\u044f, \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0441\u0435\u0431\u0435 \u0440\u0430\u0437\u0443\u043c\u043d\u043e\u0435 dev \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435. <br \/>  \u0425\u043e\u0440\u043e\u0448\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <code>npm i<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c.<\/p>\n<h4><b>\u041f\u043e\u0434\u0430\u0439\u0442\u0435 \u043c\u043d\u0435 Seymour<\/b><\/h4>\n<p>  \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"bash\">client\/ shared\/ index.js server.jsx <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432 <code>shared<\/code> \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u043d\u043e \u043d\u0443\u0436\u0435\u043d \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0441\u0442\u043a\u043e\u0439 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">index.js<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">'use strict';  require('babel\/register')({});  var server = require('.\/server');  const PORT = process.env.PORT || 3000;  server.listen(PORT, function () {   console.log('Server listening on', PORT); }); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <i><b>server.jsx<\/b><\/i>, \u0438\u0442\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ES6\/JSX.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c <a href=\"http:\/\/expressjs.com\/\">Express<\/a>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0449\u0435, \u0438 \u0435\u0441\u0442\u044c \u0448\u0430\u043d\u0441 \u0447\u0442\u043e \u0442\u044b \u0443\u0436\u0435 \u0435\u0433\u043e \u0437\u043d\u0430\u0435\u0448\u044c.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">server.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import express from 'express';  const app = express();  app.use((req, res) =&gt; {   const HTML = `   &lt;DOCTYPE html&gt;   &lt;html&gt;     &lt;head&gt;       &lt;meta charset=&quot;utf-8&quot;&gt;       &lt;title&gt;Isomorphic Redux Demo&lt;\/title&gt;     &lt;\/head&gt;     &lt;body&gt;       &lt;div id=&quot;react-view&quot;&gt;&lt;\/div&gt;       &lt;script type=&quot;application\/javascript&quot; src=&quot;\/bundle.js&quot;&gt;&lt;\/script&gt;     &lt;\/body&gt;   &lt;\/html&gt;   `;      res.end(HTML); });  export default app; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0444\u0438\u0433\u043d\u044f. \u041c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 Express \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c middleware, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0443\u0441\u0442\u0430\u044f \u0432\u0435\u0431 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 \u043f\u0443\u0441\u0442\u043e\u0442\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e.<\/p>\n<h4><b>\u0420\u043e\u0443\u0442\u0438\u043c \u043a\u0430\u043a \u043f\u0440\u043e<\/b><\/h4>\n<p>  \u0422\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u0434\u0443\u043c\u0430\u0435\u0448\u044c, \u0447\u0442\u043e \u0441 Express \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u043e\u043c \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u043a\u043e. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0442\u044b \u043e\u0448\u0438\u0431\u0430\u0435\u0448\u044c\u0441\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u0448\u0430\u0440\u0438\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/rackt\/react-router\">React Router<\/a>, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0440\u043e\u0443\u0442\u0438\u0442\u044c \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c root \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>shared\/components\/index.jsx<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430\u0448 React Router. \u0422\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0441\u0442\u0435\u0442\u0438\u043a\u0438 \u0432\u0441\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e (\u0448\u0430\u043f\u043a\u0443 \u0438 \u043f\u043e\u0434\u0432\u0430\u043b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440), \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u0431\u043b\u0435\u0441\u0442\u044f\u0449\u0435\u0433\u043e SPA.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">shared\/components\/index.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import React from 'react'; export default class AppView extends React.Component {   render() {     return (       &lt;div id=&quot;app-view&quot;&gt;         &lt;h1&gt;Todos&lt;\/h1&gt;         &lt;hr \/&gt;         {this.props.children}       &lt;\/div&gt;     );   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <i><b>children<\/b><\/i> \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u0434\u0435\u0440\u0435\u0432\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0440\u043e\u0443\u0442\u0435\u0440 \u043f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u043c\u0430\u0433\u0438\u0438 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0433\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0432\u0441\u0435 \u043a\u0430\u043a \u0435\u0441\u0442\u044c.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u043e\u0443\u0442 \u0432  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">shared\/routes.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import React     from 'react'; import { Route } from 'react-router'; import App from 'components';  export default (   &lt;Route name=&quot;app&quot; component={App} path=&quot;\/&quot;&gt;   &lt;\/Route&gt; ); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043c React Router&#8217;\u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043d\u0430\u0448 <code>components\/index<\/code> \u043f\u043e \u043f\u0443\u0442\u0438 &#8216;\/&#8217;. \u0417\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e!<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">server.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import React      from 'react'; import { Router } from 'react-router'; import Location   from 'react-router\/lib\/Location'; import routes     from 'routes';  app.use((req, res) =&gt; {   const location = new Location(req.path, req.query);    Router.run(routes, location, (err, routeState) =&gt; {     if (err) return console.error(err);          const InitialComponent = (       &lt;Router {...routeState} \/&gt;     );     const componentHTML = React.renderToString(InitialComponent);     const HTML = `...`;          res.end(HTML);   }); }); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u0443 \u043d\u043e\u0432\u044b\u0445 \u0438\u0433\u0440\u0443\u0448\u0435\u043a \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0440\u043e\u0443\u0442\u0435\u0440\u0443 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0440\u0443\u043a\u0438 express. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u044b \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a <code>routeState<\/code> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u043e\u0442 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441 \u043d\u0430\u0441 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0432\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <code>renderToString<\/code> \u0438\u0437 <b>React<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 HTML \u0441\u0442\u0440\u043e\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u0442\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0432 <b>react-view<\/b> div \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0440\u0430\u043d\u0435\u0435.<\/p>\n<pre><code class=\"html\">&lt;div id=&quot;react-view&quot;&gt;${componentHTML}&lt;\/div&gt; <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <code>npm start<\/code> \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0437\u0434\u0435\u0441\u044c <a href=\"http:\/\/localhost:3000\/\">http:\/\/localhost:3000\/<\/a>, \u0447\u0442\u043e \u0440\u043e\u0443\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u043b\u0441\u044f \u0432 HTML.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8a1\/04d\/877\/8a104d87706e3f05124546b96b536696.jpg\" alt=\"Todos route\"\/><br \/>  \u0422\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0448\u044c, \u0447\u0442\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043f\u0430\u0440\u0443 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0435, \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0443 \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u042d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043b\u0438\u0435\u043d\u0442 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c <code>bundle.js<\/code>, \u043d\u043e \u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0434\u0430\u043b\u0438 webpack&#8217;\u0443 \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043a\u0430\u044f \u0444\u0438\u0433\u043d\u044f.<\/p>\n<p>  \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0444\u0438\u0433\u0435\u043d\u043d\u043e, \u0438 \u044f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0432\u0430\u0448 \u043c\u043e\u0437\u0433 \u0443\u0436\u0435 \u043f\u043e\u0440\u0432\u0430\u043b\u043e, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0430. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u044e \u0441\u043e\u0447\u043d\u0443\u044e \u043c\u044f\u043a\u043e\u0442\u043a\u0443 \u0438\u0437 React, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435.<\/p>\n<p>  \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u043f\u0435\u0440\u0435\u0434, \u043e\u0442\u043a\u0440\u043e\u0435\u043c <code>client\/index.jsx<\/code> \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0447\u0442\u043e \u043d\u0438\u0431\u0443\u0434\u044c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">client\/index.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import React       from 'react'; import { Router }  from 'react-router'; import { history } from 'react-router\/lib\/BrowserHistory'; import routes      from 'routes';  React.render(   &lt;Router children={routes} history={history} \/&gt;,   document.getElementById('react-view') ); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041c\u044b \u0441\u043a\u0430\u0437\u0430\u043b\u0438 React&#8217;\u0443 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Router&#8217;a \u0432 <b>react-view<\/b> div, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0435\u043c\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. <b>History<\/b> \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043d\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 React Router&#8217;a (\u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e), \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 URL. \u0410 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0438 \u0447\u0438\u0441\u0442\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442! \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>HTML5 History API<\/b> \u0441 <b>BrowserHistory<\/b>, \u0445\u043e\u0442\u044f \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u044b\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>HashHistory<\/b> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c <code>\/#<\/code> URL \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <code>npm run dev<\/code> \u0438 Webpack \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448 <b>bundle.js<\/b>. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043d\u043e \u0437\u0430\u0439\u0434\u044f \u043d\u0430 <a href=\"http:\/\/localhost:8080\/\">http:\/\/localhost:8080\/<\/a> \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a. \u0421 \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u043e\u043c \u043f\u043e\u043a\u043e\u043d\u0447\u0435\u043d\u043e, \u0438 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a Redux \u044d\u043a\u0448\u0435\u043d\u0443.<\/p>\n<h4><b>Reduce, Reuse, Redux<\/b><\/h4>\n<p>  Redux \u0432\u043d\u0435\u0448\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 Flux \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044f \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0440\u0430\u043d\u0435\u0435, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u044b \u0432\u043c\u0435\u0441\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f Todo \u043b\u0438\u0441\u0442\u0430.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">shared\/actions\/TodoActions.js<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">export function createTodo(text) {   return {     type: 'CREATE_TODO',     text,     date: Date.now()   } }  export function editTodo(id, text) {   return {     type: 'EDIT_TODO',     id,     text,     date: Date.now()   }; }  export function deleteTodo(id) {   return {     type: 'DELETE_TODO',     id   }; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u0442\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u0432\u0438\u0434\u0435\u0442\u044c, \u0432 Redux \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 <i>(action creators \u043e\u0440\u0438\u0433.)<\/i>, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438, \u0434\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u044b, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0445.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">shared\/reducers\/TodoReducer.js<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import { List } from 'immutable';  const defaultState = new List();  export default function todoReducer(state = defaultState, action) {   switch(action.type) {     case 'CREATE_TODO':       return state.concat(action.text);     case 'EDIT_TODO':       return state.set(action.id, action.text);     case 'DELETE_TODO':       return state.delete(action.id);     default:       return state;   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u043f\u044f\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/facebook.github.io\/immutable-js\/docs\/#\/List\">Immutable List object<\/a>, \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (\u0445\u043e\u0442\u044f \u0432 \u0431\u043e\u043b\u0435\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435), \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>  Redux \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0443\u0436 \u0443\u043f\u0440\u044f\u043c\u044b\u0439, \u0443 \u043d\u0435\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043e\u0442 \u0441\u0432\u043e\u0438\u0445 \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u043e\u0432.  <\/p>\n<ol>\n<li>\u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 <code>(state, action) =&gt; newState<\/code>.<\/li>\n<li>\u0420\u0435\u0434\u044e\u0441\u0435\u0440 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0435 \u0435\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e.<\/li>\n<\/ol>\n<p>  \u041a\u0430\u043a \u0442\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0432\u044f\u0436\u0435\u0442\u0441\u044f \u0441 <a href=\"https:\/\/facebook.github.io\/immutable-js\/\">Immuatable.js<\/a><\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f switch \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u043d\u043e \u0435\u0441\u043b\u0438 \u0442\u0435\u0431\u0435 \u044d\u0442\u043e \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0432\u0430\u043d\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438.<\/p>\n<p>  Redux \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u0430, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>reducers\/index.js<\/code>:  <\/p>\n<pre><code class=\"javascript\">export { default as todos } from '.\/TodoReducer'; <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u043d \u043e\u0434\u0438\u043d, \u043d\u0430\u043c \u044d\u0442\u043e \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<h4><b>\u0418\u0438\u0438\u0438\u0438\u0438\u2026 \u042d\u043a\u0448\u043d!<\/b><\/h4>\n<p>  \u0420\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u044b \u043f\u0440\u043e \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u044b \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e\u0431 \u044d\u0442\u043e\u043c! \u041f\u043e\u0440\u0430 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c.<\/p>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Redux \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u0440\u0435\u0432\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0448\u0442\u0443\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435!<br \/>  \u0423 NPM \u043f\u0430\u043a\u0435\u0442\u0430 <code>react-redux<\/code> \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u043e\u0447\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043c \u0432 \u044d\u0442\u043e\u043c.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">server.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import { createStore, combineReducers } from 'redux'; import { Provider }                     from 'react-redux'; import * as reducers                    from 'reducers';  app.use((req, res, next) =&gt; {   const location = new Location(req.path, req.query);   const reducer  = combineReducers(reducers);   const store    = createStore(reducer);      Router.run(routes, location, (err, routeState) =&gt; {     if (err) return console.error(err);          const InitialView = (       &lt;Provider store={store}&gt;         {() =&gt;           &lt;Router {...routeState} \/&gt;         }       &lt;\/Provider&gt;     );  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430-\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Redux \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0432\u0441\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 (\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043a\u0430\u043a <b>&lt;component&gt;.context.redux<\/b>, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043a\u043e\u0433\u0434\u0430 \u043b\u0438\u0431\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f), \u043e\u0431\u0435\u0440\u043d\u0443\u0432 root \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 <code>Provider<\/code>.<br \/>  \u0422\u0430\u043a \u0436\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0434\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043c\u043e\u0433 \u0433\u0438\u0434\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430.<\/p>\n<p>  \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u0440\u043e\u0441\u0438\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0443 Redux:  <\/p>\n<pre><code class=\"javascript\">const initialState = store.getState(); <\/code><\/pre>\n<p>  \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 \u043d\u0430\u0448 HTML \u0448\u0430\u0431\u043b\u043e\u043d:  <\/p>\n<pre><code class=\"html\">&lt;title&gt;Redux Demo&lt;\/title&gt;      &lt;script type=&quot;application\/javascript&quot;&gt;   window.__INITIAL_STATE__ = ${JSON.stringify(initialState)}; &lt;\/script&gt; <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 <code>window.__INITIAL_STATE__<\/code>, \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0434\u0430?<br \/>  \u0427\u0442\u043e \u043d\u0430\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432 <i>Immutable.js<\/i> \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u0418 \u043e\u0442\u0434\u0430\u0442\u044c \u0438\u0445 Redux \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">client\/index.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import { createStore, combineReducers } from 'redux'; import { Provider }                     from 'react-redux'; import * as reducers                    from 'reducers'; import { fromJS }                       from 'immutable';  let initialState = window.__INITIAL_STATE__;  \/\/ Transform into Immutable.js collections, \/\/ but leave top level keys untouched for Redux Object   .keys(initialState)   .forEach(key =&gt; {     initialState[key] = fromJS(initialState[key]);    }); const reducer = combineReducers(reducers); const store   = createStore(reducer, initialState);  React.render(   &lt;Provider store={store}&gt;     {() =&gt;       &lt;Router children={routes} history={history} \/&gt;     }   &lt;\/Provider&gt;,   document.getElementById('react-view'); ); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u042d\u0442\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0433\u0438\u0434\u0440\u0438\u0440\u0443\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u043d\u0430\u043c \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  \u041c\u044b \u0432\u0435\u0440\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u043c\u0441\u044f \u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438.<\/p>\n<h4><b>\u0421\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438<\/b><\/h4>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0439 (\u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u0430\u043a \u0438 \u0435\u0441\u0442\u044c), \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 Redux \u043c\u0435\u0436\u0434\u0443 \u00ab\u0443\u043c\u043d\u044b\u043c\u0438\u00bb \u0438 \u00ab\u0442\u0443\u043f\u044b\u043c\u0438\u00bb \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<p>  \u0423\u043c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f Redux \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <i><b>@connector<\/b><\/i> \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430), \u0438 \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442 \u0435\u0433\u043e \u0432\u043d\u0438\u0437 \u043f\u043e \u0434\u0435\u0440\u0435\u0432\u0443 \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u041a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u0434\u0435\u0440\u0435\u0432\u0430, \u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u0441\u0430\u043c\u044b\u0445 \u043d\u0438\u0436\u043d\u0438\u0445 \u0441\u043b\u043e\u0435\u0432.<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">shared\/components\/Home.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import React                  from 'react'; import TodosView              from 'components\/TodosView'; import TodosForm              from 'components\/TodosForm'; import { bindActionCreators } from 'redux'; import * as TodoActions       from 'actions\/TodoActions'; import { connect }            from 'react-redux';  @connect(state =&gt; ({ todos: state.todos })) export default class Home extends React.Component {   render() {     const { todos, dispatch } = this.props;          return (       &lt;div id=&quot;todo-list&quot;&gt;         &lt;TodosView todos={todos}            {...bindActionCreators(TodoActions, dispatch)} \/&gt;         &lt;TodosForm           {...bindActionCreators(TodoActions, dispatch)} \/&gt;       &lt;\/div&gt;     );   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u0432\u0430 \u00ab\u0442\u0443\u043f\u044b\u0445\u00bb \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 <a href=\"https:\/\/github.com\/wycats\/javascript-decorators\">\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438<\/a> (<b>@connector<\/b> \u0441\u0435\u043a\u0446\u0438\u044f), \u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u044d\u0442\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0447\u0442\u043e \u0438 \u043c\u0438\u043a\u0441\u0438\u043d\u044b \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445. \u0422\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u0432 Python \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0432 javascript \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u043e\u0434\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0437\u0434\u0435\u0441\u044c \u00ab\u043a\u043b\u0430\u0441\u0441\u00bb).<\/p>\n<p>  \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <b>@connect<\/b> \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c (<code>&lt;Connector&gt;<\/code>), \u0434\u0430\u044e\u0449\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u043c \u0447\u0430\u0441\u0442\u044f\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043a\u0430\u043a \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>todos<\/code>, \u0447\u0442\u043e \u043c\u044b \u0438 \u0434\u0435\u043b\u0430\u0435\u043c. \u041e\u043d \u0442\u0430\u043a \u0436\u0435 \u0434\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>dispatch<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 Redux, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"javascript\">dispatch(actionCreator()); <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>bindActionCreators<\/code> \u0438\u0437 Redux, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<br \/>  \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0431\u0435\u0437 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0445 \u0432 <code>dispatch()<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">components\/TodosView.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import React from 'react';  export default class TodosView extends React.Component {   handleDelete = (e) =&gt; {     const id = Number(e.target.dataset.id);          \/\/ Equivalent to `dispatch(deleteTodo())`     this.props.deleteTodo(id);   }   handleEdit = (e) =&gt; {     const id  = Number(e.target.dataset.id);     const val = this.props.todos.get(id).text          \/\/ For cutting edge UX     let newVal = window.prompt('', val);     this.props.editTodo(id, newVal);   }     render() {     return (       &lt;div id=&quot;todo-list&quot;&gt;         {           this.props.todos.map( (todo, index) =&gt; {             return (               &lt;div key={index}&gt;                 &lt;span&gt;{todo}&lt;\/span&gt;                                &lt;button data-id={index} onClick={this.handleDelete}&gt;                   X                 &lt;\/button&gt;                 &lt;button data-id={index} onClick={this.handleEdit}&gt;                   Edit                 &lt;\/button&gt;               &lt;\/div&gt;             );           })         }       &lt;\/div&gt;     );   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 todo \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u0440\u044f\u0434\u043e\u043c \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435, \u043f\u0440\u043e\u0448\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u00abarrow\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 (\u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043a\u0430\u043a \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f). \u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 ES6 \u043a\u043b\u0430\u0441\u0441\u0430 (\u043a\u0430\u043a render), \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438\u0445 \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<blockquote><p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0432\u044b \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <i><b>React.createClass<\/b><\/i>, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043a\u0441\u0438\u043d\u044b, \u0445\u043e\u0442\u044f \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ES6 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u0438 \u043a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0446\u0438\u0438.  <\/p><\/blockquote>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">components\/TodosForm.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import React from 'react';  export default class TodosForm extends React.Component {   handleSubmit = () =&gt; {     let node = this.refs['todo-input'].getDOMNode();          this.props.createTodo(node.value);          node.value = '';   }      render() {     return (       &lt;div id=&quot;todo-form&quot;&gt;         &lt;input type=&quot;text&quot; placeholder=&quot;type todo&quot; ref=&quot;todo-input&quot; \/&gt;         &lt;input type=&quot;submit&quot; value=&quot;OK!&quot; onClick={this.handleSubmit} \/&gt;       &lt;\/div&gt;     );   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u042d\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u00ab\u0442\u0443\u043f\u043e\u0439\u00bb \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c todo \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u043e\u0443\u0442 \u0432<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">shared\/routes.jsx<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import Home from 'components\/Home'; export default (   &lt;Route name=&quot;app&quot; component={App} path=&quot;\/&quot;&gt;     &lt;Route component={Home} path=&quot;home&quot; \/&gt;   &lt;\/Route&gt; ); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8c7\/6b1\/dca\/8c76b1dcac85786ada77e82e4e3fcf05.jpg\" alt=\"Todo App\"\/><\/p>\n<p>  \u0418 voil\u00e0, \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0430 <a href=\"http:\/\/localhost:8080\/home\">http:\/\/localhost:8080\/home<\/a> \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/p>\n<h4><b>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0443\u0431\u0435\u0436: \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/b><\/h4>\n<p>  \u042f \u0437\u043d\u0430\u044e \u043e \u0447\u0435\u043c \u0442\u044b \u0434\u0443\u043c\u0430\u0435\u0448\u044c.<\/p>\n<p>  \u042d\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>  \u0410 \u044f \u0433\u043e\u0432\u043e\u0440\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e!<\/p>\n<p>  \u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443 Redux, \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439 middleware \u0443 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0432\u0430\u0448\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e). \u042f \u0443\u0432\u0435\u0440\u0435\u043d, \u0442\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0438\u0437 \u0442\u0435\u043c\u044b \u043f\u0440\u043e Redux, \u0447\u0442\u043e \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430\u043c\u0438.<\/p>\n<p>  \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 Redux middleware, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0449\u0435, \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043a\u0443\u0441\u043d\u044b\u0435 \u0438 \u0431\u043b\u0435\u0441\u0442\u044f\u0449\u0438\u0435 ES6 \u043f\u0440\u043e\u043c\u0438\u0441\u044b.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">shared\/lib\/promiseMiddleware.js<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">export default function promiseMiddleware() {   return next =&gt; action =&gt; {     const { promise, type, ...rest } = action;         if (!promise) return next(action);         const SUCCESS = type;     const REQUEST = type + '_REQUEST';     const FAILURE = type + '_FAILURE';     next({ ...rest, type: REQUEST });     return promise       .then(res = &gt; {         next({ ...rest, res, type: SUCCESS });                  return true;       })       .catch(error =&gt; {         next({ ...rest, error, type: FAILURE });                  \/\/ Another benefit is being able to log all failures here          console.log(error);         return false;       });    }; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c &#8216;promise&#8217; \u043a\u043b\u044e\u0447 \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u0448\u043b\u043e \u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e resolved \u0438\u043b\u0438 rejected.<br \/>  \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u044b \u0434\u043b\u044f \u0430\u0432\u0442\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 <b>&lt;TYPE&gt;_REQUEST<\/b> \u0438 <b>&lt;TYPE&gt;_FAILURE<\/b>, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043c\u0443\u0442\u0430\u0446\u0438\u044e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<p>  \u0418 \u0434\u043b\u044f \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u0432 <i><b>client\/index.jsx<\/b><\/i> \u0438 <b><i>server.jsx<\/i><\/b><\/p>\n<pre><code class=\"javascript\">... import { applyMiddleware } from 'redux'; import promiseMiddleware   from 'lib\/promiseMiddleware'; ... const store = applyMiddleware(promiseMiddleware)(createStore)(reducer); <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c <b>initialState<\/b> \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 <b>reducer<\/b><\/p>\n<p>  \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 <b><i>createTodo<\/i><\/b> \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440<\/p>\n<pre><code class=\"javascript\">import request from 'axios';  const BACKEND_URL = 'https:\/\/webtask.it.auth0.com\/api\/run\/wt-milomord-gmail_com-0\/redux-tutorial-backend?webtask_no_cache=1';  export function createTodo(text) {   return {     type: 'CREATE_TODO',     promise: request.post(BACKEND_URL, { text })   } } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u0430.  <\/p>\n<pre><code class=\"javascript\">return state.concat(action.res.data.text); <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6cb\/737\/d74\/6cb737d745a03217d2973a502b39fd0a.gif\" alt=\"Todo App with async actions\"\/><\/p>\n<p>  Todo \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u043e\u044e \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c <b>getTodos<\/b> \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<pre><code class=\"javascript\">export function getTodos() {   return {     type: 'GET_TODOS',     promise: request.get(BACKEND_URL)   } } <\/code><\/pre>\n<p>  \u041b\u043e\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u0435  <\/p>\n<pre><code class=\"javascript\">case 'GET_TODOS':   return state.concat(action.res.data); <\/code><\/pre>\n<p>  \u0418 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u0433\u0434\u0430 <i><b>TodosView<\/b><\/i> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f  <\/p>\n<pre><code class=\"javascript\">componentDidMount() {   this.props.getTodos(); } <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 middleware \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u0430\u0437\u0430, \u0442\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u0440\u0435\u0434\u044e\u0441\u0435\u0440\u0430\u0445 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<h4><b>\u041f\u043e\u0441\u0442\u043e\u0439\u2026 \u0410 \u043c\u044b \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u043b\u0438 \u0440\u0435\u0433\u0438\u0434\u0440\u0430\u0446\u0438\u044e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f?<\/b><\/h4>\n<p>  \u0414\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c!<\/p>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u043e \u043d\u0435 \u0436\u0434\u0435\u043c \u0438\u0445 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442. \u0422\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u044d\u043a\u0440\u0430\u043d \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435. \u041b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c \u0432\u0438\u0441\u0435\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0434\u0430?<\/p>\n<p>  \u041d\u0443, \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043c\u043d\u043e\u0433\u0438\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0432\u044b\u0433\u043e\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u043d\u0430\u0448\u0438\u043c \u0431\u044d\u043a\u044d\u043d\u0434\u043e\u043c (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u0442\u043e\u043c \u0436\u0435 \u0434\u0430\u0442\u0430\u0446\u0435\u043d\u0442\u0440\u0435!). \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0430\u0448 \u0441\u0430\u0439\u0442 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0436\u0434\u0430\u043b \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043d\u0435\u0436\u0435\u043b\u0438 \u0447\u0442\u043e\u0431 \u043e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u0435\u0433\u043e \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u0441\u043b\u043e\u0436\u043d\u043e. \u0422\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438, \u043f\u0443\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u0434\u0435\u043b\u0430\u044e, \u0434\u0430\u043b\u0435\u043a \u043e\u0442 \u0438\u0434\u0438\u0435\u0430\u043b\u0430:<\/p>\n<p>  \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430:  <\/p>\n<pre><code class=\"javascript\">static needs = [   TodoActions.getTodos ] <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0439\u043c\u0430\u0435\u0442 \u0432\u0441\u0435 promise \u0432\u044b\u0437\u043e\u0432\u044b, \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0438\u0445  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">shared\/lib\/fetchComponentData.js<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">export default function fetchComponentData(dispatch, components, params) {   const needs = components.reduce( (prev, current) =&gt; {     return (current.needs || [])       .concat((current.WrappedComponent ? current.WrappedComponent.needs : []) || [])       .concat(prev);     }, []);          const promises = needs.map(need =&gt; dispatch(need(params)));     return Promise.all(promises); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u043b\u044e\u0447 <b>WrappedComponent<\/b>, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u00ab\u0443\u043c\u043d\u044b\u0435\u00bb \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044b \u0432 <b><i>Connector<\/i><\/b> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.  <\/p>\n<pre><code class=\"javascript\">import fetchComponentData from 'lib\/fetchComponentData';  Router.run(routes, location, (err, routeState) =&gt; {   if (err) return console.error(err);      function renderView() {     \/\/ ... Rest of the old code goes here     return HTML;     }      \/\/ Check this is rendering *something*, for safety   if(routeState)     fetchComponentData(store.dispatch, routeState.components, routeState.params)       .then(renderView)       .then(html =&gt; res.end(html))       .catch(err =&gt; res.end(err.message)); }); <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f25\/5c3\/148\/f255c3148f2cef5191fde8714d1509f9.gif\" alt=\"Wait for server async data complete\"\/><\/p>\n<p>  \u0423\u0431\u0435\u0434\u0438\u0441\u044c, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438\u0437 <b><i>onComponentMount<\/i><\/b>, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438 <code>npm run dev<\/code> \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<h4><b>\u0427\u0442\u043e \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438?<\/b><\/h4>\n<p>  \u0427\u0442\u043e \u043c\u0438\u0440 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u0435\u043d!<\/p>\n<p>  \u041c\u043d\u043e\u0433\u043e\u0435 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e. \u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0440\u043e\u0443\u0442\u043e\u0432, \u0442\u0435\u0431\u0435 \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c React Router <b><i>onLeave<\/i><\/b> \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 (\u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/bananaoomarang\/chapters\/blob\/master\/client\/index.jsx#L36\">\u0442\u0443\u0442<\/a>), \u0438 \u043b\u043e\u0432\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c API.<\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0432\u0441\u0435 \u044d\u0442\u043e, \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0442\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0441\u0435\u0431\u0435 \u043d\u0430\u0441\u043b\u0430\u0434\u0438\u0442\u0441\u044f \u044d\u043f\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043a\u0432\u0435\u0441\u0442\u043e\u043c \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0431\u0443\u0434\u0443\u0449\u0435\u0435. <\/p>\n<p>  \u0422\u044b \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u0448\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 <a href=\"https:\/\/github.com\/bananaoomarang\/isomorphic-redux\">Github<\/a> \u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e Redux <a href=\"https:\/\/github.com\/gaearon\/redux\">\u0437\u0434\u0435\u0441\u044c<\/a>   \t<\/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\/264423\/\"> http:\/\/habrahabr.ru\/post\/264423\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0418\u0442\u0430\u043a, \u044f \u0437\u043d\u0430\u044e \u0447\u0442\u043e \u0442\u044b \u043b\u044e\u0431\u0438\u0448\u044c Todo \u0441\u043f\u0438\u0441\u043a\u0438, \u0442\u043e \u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u0431\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c Todo \u0441\u043f\u0438\u0441\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0442\u044b \u0441\u043e\u0437\u0434\u0430\u043b \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u043e\u0432\u044b\u0439, \u0432\u043e\u0441\u0445\u0438\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438 \u043f\u0438\u0442\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 <i>(\u00abnutritious\u00bb \u043f\u0440\u0438\u043c. \u043f\u0435\u0440.)<\/i> Flux \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, <a href=\"https:\/\/github.com\/gaearon\/redux\">Redux<\/a>! \u042f \u0436\u0435\u043b\u0430\u044e \u0442\u0435\u0431\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0443\u0447\u0448\u0435\u0433\u043e.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0442\u044b \u043d\u0430\u0443\u0447\u0438\u0448\u044c\u0441\u044f \u043a\u0430\u043a \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 Redux \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044f\u0441\u044c, \u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f.<\/p>\n<ul>\n<li>\u0426\u0435\u043b\u044c\u043d\u043e\u0437\u0435\u0440\u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435<\/li>\n<li>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 \u0440\u043e\u0443\u0442\u0438\u043d\u0433, \u0431\u043e\u0433\u0430\u0442\u044b\u0439 Omega-3<\/li>\n<li>\u041c\u0430\u0441\u043b\u044f\u043d\u0438\u0441\u0442\u0430\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li>\u0413\u043b\u0430\u0434\u043a\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0441\u043b\u0435\u0432\u043a\u0443\u0441\u0438\u0435<\/li>\n<\/ul>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0435\u0433\u043e \u0442\u044b \u0445\u043e\u0447\u0435\u0448\u044c \u0432 \u044d\u0442\u043e\u0439 \u0436\u0438\u0437\u043d\u0438, \u0432\u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0434 \u043a\u0430\u0442, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0439\u0441\u044f.  <\/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-263369","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263369","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=263369"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263369\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}