{"id":261058,"date":"2015-07-09T17:35:02","date_gmt":"2015-07-09T13:35:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=261058"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=261058","title":{"rendered":"React \u043d\u0430 ES6+"},"content":{"rendered":"<p>       \u042d\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043f\u043e\u0441\u0442\u0430 <a href=\"https:\/\/github.com\/steveluscher\">Steven Luscher<\/a> \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u0431\u043b\u043e\u0433\u0435 <a href=\"http:\/\/babeljs.io\/blog\/\">Babel<\/a>. Steven \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 Facebook \u043d\u0430\u0434 <a href=\"https:\/\/facebook.github.io\/react\/blog\/2015\/02\/20\/introducing-relay-and-graphql.html\">Relay<\/a> \u2013 JavaScript \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c React \u0438 GraphQL.  <\/p>\n<blockquote><p>\u0417\u0430 \u044d\u0442\u043e\u0442 \u0433\u043e\u0434, \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0435\u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 <a href=\"https:\/\/instagram.com\/instagram\/\">Instagram Web<\/a>, \u043c\u044b \u043d\u0430\u0441\u043b\u0430\u0434\u0438\u043b\u0438\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u044f\u0434\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 ES6+, \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u0430\u0448\u0445 React \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u0435\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445, \u043a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0442\u043e \u043a\u0430\u043a \u0432\u044b \u043f\u0438\u0448\u0438\u0442\u0435 React \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043b\u0435\u0433\u0447\u0435 \u0438 \u0432\u0435\u0441\u0435\u043b\u0435\u0435, \u0447\u0435\u043c \u043a\u043e\u0433\u0434\u0430-\u043b\u0438\u0431\u043e.  <\/p><\/blockquote>\n<p><a name=\"habracut\"><\/a><\/p>\n<h4>\u041a\u043b\u0430\u0441\u0441\u044b<\/h4>\n<p>  \u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c \u0438\u0437 \u0432\u0438\u0434\u0438\u043c\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0438 React \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f ES6+ \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/babeljs.io\/docs\/learn-es2015\/#classes\">\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430<\/a>. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>React.createClass<\/i> \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 ES6 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 <i>React.Component<\/i>:<\/p>\n<pre><code class=\"javascript\">class Photo extends React.Component {   render() {     return &lt;img alt={this.props.caption} src={this.props.src} \/&gt;;   } } <\/code><\/pre>\n<p>  \u0412\u044b \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u2014 \u0432\u0430\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0431\u043e\u043b\u0435\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"javascript\">\/\/ The ES5 way var Photo = React.createClass({   handleDoubleTap: function(e) { \u2026 },   render: function() { \u2026 }, }); <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ The ES6+ way class Photo extends React.Component {   handleDoubleTap(e) { \u2026 }   render() { \u2026 } } <\/code><\/pre>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043b\u0438 \u0434\u0432\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439, \u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043c\u044b \u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435, \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <i>function<\/i> \u0438 \u0437\u0430\u043f\u044f\u0442\u0443\u044e.<\/p>\n<p>  \u0412\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u0440\u043e\u043c\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0436\u0438\u0434\u0430\u0442\u044c, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0440\u043e\u043b\u0438 \u0440\u0430\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <i>componentWillMount<\/i>:<\/p>\n<pre><code class=\"javascript\">\/\/ The ES5 way var EmbedModal = React.createClass({   componentWillMount: function() { \u2026 }, }); <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ The ES6+ way class EmbedModal extends React.Component {   constructor(props) {     super(props);     \/\/ Operations usually carried out in componentWillMount go here   } } <\/code><\/pre>\n<h4>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/h4>\n<p>  \u0412 \u043c\u0438\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 ES6+, \u0442\u0438\u043f\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u043e\u0433\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u042d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c ES7 <a href=\"https:\/\/gist.github.com\/jeffmo\/054df782c05639da2adb\">\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/a>:<\/p>\n<pre><code class=\"javascript\">\/\/ The ES5 way var Video = React.createClass({   getDefaultProps: function() {     return {       autoPlay: false,       maxLoops: 10,     };   },   getInitialState: function() {     return {       loopsRemaining: this.props.maxLoops,     };   },   propTypes: {     autoPlay: React.PropTypes.bool.isRequired,     maxLoops: React.PropTypes.number.isRequired,     posterFrameSrc: React.PropTypes.string.isRequired,     videoSrc: React.PropTypes.string.isRequired,   }, }); <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ The ES6+ way class Video extends React.Component {   static defaultProps = {     autoPlay: false,     maxLoops: 10,   }   static propTypes = {     autoPlay: React.PropTypes.bool.isRequired,     maxLoops: React.PropTypes.number.isRequired,     posterFrameSrc: React.PropTypes.string.isRequired,     videoSrc: React.PropTypes.string.isRequired,   }   state = {     loopsRemaining: this.props.maxLoops,   } } <\/code><\/pre>\n<p>  \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432 ES7 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0433\u0434\u0435 <i>this<\/i> \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443, \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442\u044c \u043e\u0442 <i>this.props<\/i>. \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <i>props<\/i> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 <i>getter<\/i> \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<h4>Arrow \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>React.createClass<\/i> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0431\u043e\u0442 \u043f\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0435 \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0438\u0445, \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <i>this<\/i> \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"javascript\">\/\/ Autobinding, brought to you by React.createClass var PostInfo = React.createClass({   handleOptionsButtonClick: function(e) {     \/\/ Here, 'this' refers to the component instance.     this.setState({showOptionsModal: true});   }, }); <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 <i>React.createClass<\/i>, \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 ES6+, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430, \u0442\u0443\u0434\u0430 \u0433\u0434\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">\/\/ Manually bind, wherever you need to class PostInfo extends React.Component {   constructor(props) {     super(props);     \/\/ Manually bind this method to the component instance...     this.handleOptionsButtonClick = this.handleOptionsButtonClick.bind(this);   }   handleOptionsButtonClick(e) {     \/\/ ...to ensure that 'this' refers to the component instance here.     this.setState({showOptionsModal: true});   } } <\/code><\/pre>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043f\u0443\u0442\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 ES6+ \u2013 <a href=\"https:\/\/babeljs.io\/docs\/learn-es2015\/#arrows\">arrow \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/a> \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u2013 \u043e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u0438\u043c:<\/p>\n<pre><code class=\"javascript\">class PostInfo extends React.Component {   handleOptionsButtonClick = (e) =&gt; {     this.setState({showOptionsModal: true});   } } <\/code><\/pre>\n<p>  \u0422\u0435\u043b\u043e ES6 arrow \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e \u0436\u0435 \u043b\u0435\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 <i>this<\/i> \u043a\u0430\u043a \u0438 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0445 \u043e\u043a\u0440\u0443\u0436\u0430\u0435\u0442. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e ES7 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438. <a href=\"https:\/\/babeljs.io\/repl\/#?experimental=true&amp;evaluate=true&amp;loose=false&amp;spec=false&amp;code=class%20PostInfo%20extends%20React.Component%20%7B%0A%09handleOptionsButtonClick%20%3D%20(e)%20%3D%3E%20%7B%0A%20%20%20%20this.setState(%7BshowOptionsModal%3A%20true%7D)%3B%0A%20%20%7D%0A%7D\">\u0417\u0430\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442<\/a>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<h4>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438<\/h4>\n<p>  \u041e\u0434\u043d\u0438\u043c \u0438\u0437 <a href=\"https:\/\/babeljs.io\/docs\/learn-es2015\/#enhanced-object-literals\">\u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/a> \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">var Form = React.createClass({   onChange: function(inputName, e) {     var stateToSet = {};     stateToSet[inputName + 'Value'] = e.target.value;     this.setState(stateToSet);   }, }); <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u0435\u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c JavaScript \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/babeljs.io\/docs\/learn-es2015\/#template-strings\">\u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438<\/a>, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e-\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">class Form extends React.Component {   onChange(inputName, e) {     this.setState({       [`${inputName}Value`]: e.target.value,     });   } } <\/code><\/pre>\n<h4>\u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/h4>\n<p>  \u0427\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043a \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435 \u0438\u0437 \u043d\u0438\u0445. \u0412 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 ES6+ <a href=\"https:\/\/babeljs.io\/docs\/learn-es2015\/#destructuring\">\u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/a> \u0438 <a href=\"https:\/\/facebook.github.io\/react\/docs\/jsx-spread.html\">\u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/a> JSX, \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0431\u0435\u0437 \u043f\u043b\u044f\u0441\u043e\u043a \u0441 \u0431\u0443\u0431\u043d\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">class AutoloadingPostsGrid extends React.Component {   render() {     var {       className,       ...others,  \/\/ contains all properties of this.props except for className     } = this.props;     return (       &lt;div className={className}&gt;         &lt;PostsGrid {...others} \/&gt;         &lt;button onClick={this.handleLoadMoreClick}&gt;Load more&lt;\/button&gt;       &lt;\/div&gt;     );   } } <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0447\u0435\u0442\u0430\u0442\u044c JSX \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0441 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u042d\u0442\u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <i>className<\/i>, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <i>className<\/i> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 <i>this.props<\/i>:<\/p>\n<pre><code class=\"javascript\">&lt;div {...this.props} className=&quot;override&quot;&gt;   \u2026 &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0410\u0442\u0440\u0438\u0431\u0443\u0442 <i>className<\/i> \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u00abbase\u00bb, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <i>className<\/i> \u0432 <i>this.props<\/i> \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"javascript\">&lt;div className=&quot;base&quot; {...this.props}&gt;   \u2026 &lt;\/div&gt; <\/code><\/pre>\n<h4>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0447\u0442\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u0432\u0430\u043c, \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u043d\u0430\u043c, \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430 ES6+ \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f React \u043a\u043e\u0434\u0430. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u043c\u043e\u0438\u043c \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c \u0437\u0430 \u0438\u0445 \u0432\u043a\u043b\u0430\u0434 \u0432 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u0438 \u043e\u0441\u043e\u0431\u0430\u044f \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0435 Babel \u0437\u0430 \u0442\u043e \u0447\u0442\u043e \u043e\u043d\u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u0430\u0441, \u0443\u0436\u0435 \u0441\u0435\u0433\u043e\u0434\u043d\u044f.   \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\/262183\/\"> http:\/\/habrahabr.ru\/post\/262183\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u042d\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043f\u043e\u0441\u0442\u0430 <a href=\"https:\/\/github.com\/steveluscher\">Steven Luscher<\/a> \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u0431\u043b\u043e\u0433\u0435 <a href=\"http:\/\/babeljs.io\/blog\/\">Babel<\/a>. Steven \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 Facebook \u043d\u0430\u0434 <a href=\"https:\/\/facebook.github.io\/react\/blog\/2015\/02\/20\/introducing-relay-and-graphql.html\">Relay<\/a> \u2013 JavaScript \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c React \u0438 GraphQL.  <\/p>\n<blockquote><p>\u0417\u0430 \u044d\u0442\u043e\u0442 \u0433\u043e\u0434, \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0435\u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 <a href=\"https:\/\/instagram.com\/instagram\/\">Instagram Web<\/a>, \u043c\u044b \u043d\u0430\u0441\u043b\u0430\u0434\u0438\u043b\u0438\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u044f\u0434\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 ES6+, \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u0430\u0448\u0445 React \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u0435\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445, \u043a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0442\u043e \u043a\u0430\u043a \u0432\u044b \u043f\u0438\u0448\u0438\u0442\u0435 React \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043b\u0435\u0433\u0447\u0435 \u0438 \u0432\u0435\u0441\u0435\u043b\u0435\u0435, \u0447\u0435\u043c \u043a\u043e\u0433\u0434\u0430-\u043b\u0438\u0431\u043e.  <\/p><\/blockquote>\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-261058","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/261058","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=261058"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/261058\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=261058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=261058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=261058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}