{"id":282031,"date":"2016-12-05T22:15:04","date_gmt":"2016-12-05T19:15:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282031"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282031","title":{"rendered":"React.js \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u0427\u0430\u0441\u0442\u044c \u0441\u0435\u0434\u044c\u043c\u0430\u044f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/97a\/b1c\/128\/97ab1c1280aa452c918b8aa9a77e2fae.png\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 React.js \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<\/p>\n<h3>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/h3>\n<p>  1 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/315466\/\">\u0427\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u0430\u044f<\/a> <br \/>  2 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/315630\/\">\u0427\u0430\u0441\u0442\u044c \u0432\u0442\u043e\u0440\u0430\u044f<\/a><br \/>  3 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/315716\/\">\u0427\u0430\u0441\u0442\u044c \u0442\u0440\u0435\u0442\u044c\u044f<\/a><br \/>  4 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/315922\/\">\u0427\u0430\u0441\u0442\u044c \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f<\/a><br \/>  5 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/316262\/\">\u0427\u0430\u0441\u0442\u044c \u043f\u044f\u0442\u0430\u044f<\/a><br \/>  6 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/316600\/\">\u0427\u0430\u0441\u0442\u044c \u0448\u0435\u0441\u0442\u0430\u044f<\/a><br \/>  7 \u2014 \u0427\u0430\u0441\u0442\u044c \u0441\u0435\u0434\u044c\u043c\u0430\u044f \u2014 \u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433<br \/>  8 \u2014 \u0427\u0430\u0441\u0442\u044c \u0441\u0435\u0434\u044c\u043c\u0430\u044f (\u0441\u043a\u043e\u0440\u043e)<\/p>\n<h1>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433<\/h1>\n<p>  \u0412 <i>React<\/i> \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u043b\u043e\u0449\u0430\u044e\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0432\u0430\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u0417\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  \u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0432 <i>React<\/i> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 <i>JavaScript<\/i>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b <i>JavaScript<\/i>, \u043a\u0430\u043a &quot;<i>if<\/i>&quot; \u0438\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0438 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c <i>React<\/i> \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0447\u0442\u043e\u0431\u044b \u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435:  <\/p>\n<pre><code class=\"javascript\">function UserGreeting(props) {   return &lt;h1&gt;Welcome back!&lt;\/h1&gt;; }  function GuestGreeting(props) {   return &lt;h1&gt;Please sign up.&lt;\/h1&gt;; } <\/code><\/pre>\n<p>  \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043e\u0431\u0430 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432\u043e\u0448\u0435\u043b \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443:  <\/p>\n<pre><code class=\"javascript\">function Greeting(props) {   const isLoggedIn = props.isLoggedIn;   if (isLoggedIn) {     return &lt;UserGreeting \/&gt;;   }   return &lt;GuestGreeting \/&gt;; }  ReactDOM.render(   \/\/ Try changing to isLoggedIn={true}:   &lt;Greeting isLoggedIn={false} \/&gt;,   document.getElementById('root') ); <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u0430 <a href=\"https:\/\/codepen.io\/gaearon\/pen\/ZpVxNq?editors=0011\">CodePen<\/a>.<\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u043e\u0440\u044b isLoggedIn.<\/p>\n<h2>\u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h2>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f. <\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0412\u0445\u043e\u0434\u0430 \u0438 \u0412\u044b\u0445\u043e\u0434\u0430:  <\/p>\n<pre><code class=\"javascript\">function LoginButton(props) {   return (     &lt;button onClick={props.onClick}&gt;       Login     &lt;\/button&gt;   ); }  function LogoutButton(props) {   return (     &lt;button onClick={props.onClick}&gt;       Logout     &lt;\/button&gt;   ); } <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f &quot;<i>LoginControl<\/i>&quot;. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043b\u0438\u0431\u043e &quot;<i>LoginButton<\/i>&quot;, \u043b\u0438\u0431\u043e &quot;<i>LogoutButton<\/i>&quot; \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041e\u043d \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 &quot;<i>Greeting<\/i>&quot;\u00a0\u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430:  <\/p>\n<pre><code class=\"javascript\">class LoginControl extends React.Component {   constructor(props) {     super(props);     this.handleLoginClick = this.handleLoginClick.bind(this);     this.handleLogoutClick = this.handleLogoutClick.bind(this);     this.state = {isLoggedIn: false};   }    handleLoginClick() {     this.setState({isLoggedIn: true});   }    handleLogoutClick() {     this.setState({isLoggedIn: false});   }    render() {     const isLoggedIn = this.state.isLoggedIn;      let button = null;     if (isLoggedIn) {       button = &lt;LogoutButton onClick={this.handleLogoutClick} \/&gt;;     } else {       button = &lt;LoginButton onClick={this.handleLoginClick} \/&gt;;     }      return (       &lt;div&gt;         &lt;Greeting isLoggedIn={isLoggedIn} \/&gt;         {button}       &lt;\/div&gt;     );   } }  ReactDOM.render(   &lt;LoginControl \/&gt;,   document.getElementById('root') ); <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u0430 <a href=\"https:\/\/codepen.io\/gaearon\/pen\/QKzAgB?editors=0010\">CodePen<\/a>.<\/p>\n<p>  \u0412\u0432\u043e\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 &quot;<i>if<\/i>&quot; \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043d\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043a\u0430\u043a \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432 JSX.<\/p>\n<h3>\u041a\u0430\u043a \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u00abIf\u00bb \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 (&#038;&#038;)<\/h3>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 JSX \u043f\u0443\u0442\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438. \u042d\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <i>(&#038;&#038;) JavaScript<\/i>. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:  <\/p>\n<pre><code class=\"javascript\">function Mailbox(props) {   const unreadMessages = props.unreadMessages;   return (     &lt;div&gt;       &lt;h1&gt;Hello!&lt;\/h1&gt;       {unreadMessages.length &gt; 0 &&         &lt;h2&gt;           You have {unreadMessages.length} unread messages.         &lt;\/h2&gt;       }     &lt;\/div&gt;   ); }  const messages = ['React', 'Re: React', 'Re:Re: React']; ReactDOM.render(   &lt;Mailbox unreadMessages={messages} \/&gt;,   document.getElementById('root') ); <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u0430 <a href=\"https:\/\/codepen.io\/gaearon\/pen\/ozJddz?editors=0010\">CodePen<\/a>.<\/p>\n<p>  \u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 <i>JavaScript \u00abtrue &#038;&#038; expression\u00bb<\/i> \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 &quot;<i>expression<\/i>&quot;, \u0430 &quot;<i>false &#038;&#038; expression<\/i>&quot;\u00a0\u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 &quot;<i>false<\/i>&quot;. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 &quot;<i>True<\/i>&quot;, \u0442\u043e \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u043e\u0441\u043b\u0435 <i>&#038;&#038;<\/i>. \u0415\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 &quot;<i>false<\/i>&quot;, \u0442\u043e <i>React<\/i> \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442 \u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442 \u0435\u0433\u043e.<\/p>\n<h4>\u041a\u0430\u043a \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u00abIf-Else\u00bb \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430<\/h4>\n<p>  \u0414\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 -\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <i>\u00abcondition? true: false\u00bb \u0432 JavaScript<\/i>. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0430.  <\/p>\n<pre><code class=\"javascript\">render() {   const isLoggedIn = this.state.isLoggedIn;   return (     &lt;div&gt;       The user is &lt;b&gt;{isLoggedIn ? 'currently' : 'not'}&lt;\/b&gt; logged in.     &lt;\/div&gt;   ); } It can also be used for larger expressions although it is less obvious what's going on:  render() {   const isLoggedIn = this.state.isLoggedIn;   return (     &lt;div&gt;       {isLoggedIn ? (         &lt;LogoutButton onClick={this.handleLogoutClick} \/&gt;       ) : (         &lt;LoginButton onClick={this.handleLoginClick} \/&gt;       )}     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0438 \u0432 <i>JavaScript<\/i> \u0432\u044b\u0431\u043e\u0440 \u0441\u0442\u0438\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0430\u0441. \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438, \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<h4>\u041a\u0430\u043a \u0443\u0431\u0435\u0440\u0435\u0447\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430<\/h4>\n<p>  \u0412 \u0440\u0435\u0434\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u044b\u043b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0435\u0440\u043d\u0438\u0442\u0435 &quot;<i>null<\/i>&quot; \u0432\u043c\u0435\u0441\u0442\u043e \u0435\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 &quot;<i>WarningBanner<\/i>&quot; \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u043b\u0430\u0433\u0430, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &quot;<i>warn<\/i>&quot;. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 &quot;<i>false<\/i>&quot;, \u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f.  <\/p>\n<pre><code class=\"javascript\">function WarningBanner(props) {   if (!props.warn) {     return null;   }    return (     &lt;div className=&quot;warning&quot;&gt;       Warning!     &lt;\/div&gt;   ); }  class Page extends React.Component {   constructor(props) {     super(props);     this.state = {showWarning: true}     this.handleToggleClick = this.handleToggleClick.bind(this);   }    handleToggleClick() {     this.setState(prevState =&gt; ({       showWarning: !prevState.showWarning     }));   }    render() {     return (       &lt;div&gt;         &lt;WarningBanner warn={this.state.showWarning} \/&gt;         &lt;button onClick={this.handleToggleClick}&gt;           {this.state.showWarning ? 'Hide' : 'Show'}         &lt;\/button&gt;       &lt;\/div&gt;     );   } }  ReactDOM.render(   &lt;Page \/&gt;,   document.getElementById('root') ); <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u0430 <a href=\"https:\/\/codepen.io\/gaearon\/pen\/Xjoqwm?editors=0010\">CodePen<\/a>.<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\/316896\/\"> https:\/\/habrahabr.ru\/post\/316896\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/97a\/b1c\/128\/97ab1c1280aa452c918b8aa9a77e2fae.png\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 React.js \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<\/p>\n<h3>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/h3>\n<p>  1 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/315466\/\">\u0427\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u0430\u044f<\/a> <br \/>  2 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/315630\/\">\u0427\u0430\u0441\u0442\u044c \u0432\u0442\u043e\u0440\u0430\u044f<\/a><br \/>  3 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/315716\/\">\u0427\u0430\u0441\u0442\u044c \u0442\u0440\u0435\u0442\u044c\u044f<\/a><br \/>  4 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/315922\/\">\u0427\u0430\u0441\u0442\u044c \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f<\/a><br \/>  5 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/316262\/\">\u0427\u0430\u0441\u0442\u044c \u043f\u044f\u0442\u0430\u044f<\/a><br \/>  6 \u2014 <a href=\"https:\/\/habrahabr.ru\/post\/316600\/\">\u0427\u0430\u0441\u0442\u044c \u0448\u0435\u0441\u0442\u0430\u044f<\/a><br \/>  7 \u2014 \u0427\u0430\u0441\u0442\u044c \u0441\u0435\u0434\u044c\u043c\u0430\u044f \u2014 \u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433<br \/>  8 \u2014 \u0427\u0430\u0441\u0442\u044c \u0441\u0435\u0434\u044c\u043c\u0430\u044f (\u0441\u043a\u043e\u0440\u043e)<\/p>\n<h1>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433<\/h1>\n<p>  \u0412 <i>React<\/i> \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u043b\u043e\u0449\u0430\u044e\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0432\u0430\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u0417\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  \u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0432 <i>React<\/i> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 <i>JavaScript<\/i>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b <i>JavaScript<\/i>, \u043a\u0430\u043a &quot;<i>if<\/i>&quot; \u0438\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0438 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c <i>React<\/i> \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0447\u0442\u043e\u0431\u044b \u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c.  <\/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-282031","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282031","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=282031"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282031\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}