{"id":281126,"date":"2016-11-17T15:50:03","date_gmt":"2016-11-17T12:50:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=281126"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=281126","title":{"rendered":"ReactJS: \u043e\u0442\u043a\u0430\u0437 \u043e\u0442 JSX \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430"},"content":{"rendered":"<p>ReactJS \u2014 \u044d\u0442\u043e Javascript \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e DOM. ReactJS \u0441\u0442\u0430\u043b \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d \u0437\u0430 \u0442\u043e\u0442 \u0433\u043e\u0434, \u043a\u0430\u043a \u0435\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0430 \u0432 \u0441\u0432\u0435\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f Facebook. \u0412 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0436\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u043a \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e ReactJS \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0435, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0431\u044b\u0441\u0442\u0440\u043e.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e ReactJS \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043c\u0435\u0441\u0438 HTML \u0438 Javascript \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre>    render: function(){        return &lt;div&gt;         &lt;div class=&quot;clicker&quot; onMouseDown={this.handleMouseDown}&gt;           Give me the message!         &lt;\/div&gt;         &lt;div class=&quot;message&quot;&gt;Message conveyed           &lt;span class=&quot;count&quot;&gt;{this.state.count}&lt;\/span&gt; time(s)&lt;\/div&gt;       &lt;\/div&gt;       ;     } <\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f JSX \u0438 \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 Javascript. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre> render: function(){    return React.DOM.div(null,     React.DOM.div( {className:&quot;clicker&quot;, onMouseDown:this.handleMouseDown},  &quot; Give me the message! &quot;   ),    React.DOM.div( {className:&quot;message&quot;}, &quot;Message conveyed &quot;,    React.DOM.span( {className:&quot;count&quot;}, this.state.count), &quot; time(s)&quot;)   )   ;  } <\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JSX \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 Javascript, \u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0438\u0439 \u0438 \u043c\u0435\u043d\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 JSX \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0440\u044f\u0434 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u043a\u0430\u043a \u0442\u043e:<\/p>\n<p>  * \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 JSX<br \/>  * \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0434\u043b\u044f \u043f\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 JSX<br \/>  * \u043e\u0442\u043a\u0430\u0437 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f TypeScript<\/p>\n<p>  \u041e\u0442\u043a\u0430\u0437 \u043e\u0442 TypeScript \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0438\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0442\u0430\u043a\u0430\u044f \u0438\u0434\u0435\u044f: \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043e\u0431\u044c\u0435\u043a\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Javascript \u0438 \u0437\u0430\u0442\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 React.DOM, \u043e\u043f\u044f\u0442\u044c \u043d\u0430 Javascript, \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0437 JSX. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0442\u0430\u043a:<\/p>\n<pre> render: function () {          var dom = [           {             tag: React.DOM.div,             props: {                className: &quot;class1&quot;,               onClick: this.handleClick            },            content: &quot;Hello &quot; + this.state.value           },           {             tag: React.DOM.span,             props: { },             dom: [               {                 tag: React.DOM.span,                 props: { className: &quot;class2&quot; },                 content: &quot;Hello &quot; + this.state.value               }             ]           }         ];          return parse(dom);       } <\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 3 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430: tag, props \u0438 dom (\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b) \u0438\u043b\u0438 content (\u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0439). \u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f ReactJS \u0442\u0430\u043a\u0430\u044f:<\/p>\n<pre> function parse(dom, inner) {        var items = [];        for (var el in dom) {          if (dom[el].dom) {           items.push(dom[el].tag(dom[el].props, parse(dom[el].dom, inner || true)));         } else {           items.push(dom[el].tag(dom[el].props, dom[el].content));         }       }        if (inner) {         return items.length == 1 ? items[0] : items;       } else {         return items.length == 1 ? items[0] : React.DOM.section(null, items);       }     } <\/pre>\n<p>  \u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u0417\u0430\u043c\u0435\u0442\u043d\u044b\u0445 \u043f\u043e\u0442\u0435\u0440\u044c \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435 \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e, \u043d\u043e \u043d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e, \u0447\u0442\u043e \u043d\u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445 \u0432\u0441\u0435-\u0436\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c DOM \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432 React. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u044d\u0442\u043e\u0442 \u0448\u0430\u0433 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0434\u0438\u0438, \u043f\u043e\u0441\u043b\u0435 \u0443\u0442\u0440\u044f\u0441\u043a\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/315506\/\"> https:\/\/habrahabr.ru\/post\/315506\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ReactJS \u2014 \u044d\u0442\u043e Javascript \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e DOM. ReactJS \u0441\u0442\u0430\u043b \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d \u0437\u0430 \u0442\u043e\u0442 \u0433\u043e\u0434, \u043a\u0430\u043a \u0435\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0430 \u0432 \u0441\u0432\u0435\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f Facebook. \u0412 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0436\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u043a \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e ReactJS \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0435, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0431\u044b\u0441\u0442\u0440\u043e.  <\/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-281126","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/281126","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=281126"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/281126\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=281126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=281126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=281126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}