{"id":312997,"date":"2020-11-12T03:00:55","date_gmt":"2020-11-12T03:00:55","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=312997"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=312997","title":{"rendered":"\u0412\u0441\u0435 \u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043e React key?"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>  <\/p>\n<p>\u042f \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0438 \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f <em>React key<\/em>, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u044f \u0432\u0438\u0436\u0443 \u043d\u0435\u0434\u043e\u0443\u043c\u0435\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0430\u043c\u0435\u043a\u0430\u044e\u0449\u0438\u0439 \u201c\u0414\u0430, \u0442\u0430\u043c \u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u043e\u0434\u0435 \u043d\u0435\u0447\u0435\u0433\u043e?\u201d. \u0415\u0441\u043b\u0438 \u0412\u0430\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f <em>React key<\/em> \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0442\u043e\u0433\u0434\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043c\u0438\u043d\u0438 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 (<a href=\"https:\/\/youtu.be\/OtAlPwW8DNU\" rel=\"nofollow\">\u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u043e\u0439 \u0432\u0438\u0434\u0435\u043e<\/a>)<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"zadachka-razminka\">\u0417\u0430\u0434\u0430\u0447\u043a\u0430 \u0440\u0430\u0437\u043c\u0438\u043d\u043a\u0430<\/h2>\n<p>  <\/p>\n<h3 id=\"postanovka-zadachi\">\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0430\u044f, \u0432\u0441\u0435\u0433\u043e 2 \u043f\u043e\u043b\u044f, \u044d\u0442\u043e id \u2014 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0438 \u0432\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043b\u0435 name \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const users = [{   id: 1,   name: 'Alexander', }, {   id: 2,   name: 'Dmitriy', }, {   id: 3,   name: 'Anton', }];<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const Users = ({ users }) =&gt; {   return users.map((user) =&gt; {     return (       &lt;User         key={user.id}         name={user.name}       \/&gt;     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <strong>User<\/strong>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class User extends PureComponent {   componentDidMount() {     console.log(&quot;DID MOUNT  &quot;, this.props.name);   }   componentDidUpdate(prevProps) {     console.log(&quot;DID UPDATE  &quot;, prevProps.name, &quot; -&gt; &quot;, this.props.name);   }   componentWillUnmount() {     console.log(&quot;WILL UNMOUNT  &quot;, this.props.name);   }   render() {     return (       &lt;span&gt;{this.props.name}&lt;\/span&gt;     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430\u0445, \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430. \u0418 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u044d\u0442\u043e \u2014 <strong>PureComponent<\/strong>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0441\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 (props).<\/p>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-p\/7h\/ch\/-p7hch89wgilp8v2ea3hnr8_atg.jpeg\">  <\/p>\n<p>  \u041c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 \u0442\u0440\u0435\u0445 \u0438\u043c\u0435\u043d, \u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u0438\u0434\u0438\u043c \u0442\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e DID MOUNT \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e\u043a\u0430 \u0432\u0441\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e.<\/p>\n<p>  <\/p>\n<h3 id=\"intriga-zadachi-i-vopros\">\u0418\u043d\u0442\u0440\u0438\u0433\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0412\u043e\u043f\u0440\u043e\u0441<\/h3>\n<p>  <\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0438\u043d\u0442\u0440\u0438\u0433\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0438\u043c\u044f, \u0443 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a\u0430\u043a \u0431\u044b \u044d\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u043d\u0435 \u0437\u0432\u0443\u0447\u0430\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c id, \u0430 \u0443 \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const users = [{   id: 1,   name: 'Maxim', \/\/ 'Alexander', }, {   id: 4, \/\/ 2,   name: 'Dmitriy', }, {   id: 3,   name: 'Anton', }];<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441!<br \/>  \u041a\u0430\u043a\u0438\u0435 \u043d\u043e\u0432\u044b\u0435 \u043b\u043e\u0433\u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438?<\/strong><\/p>\n<p>  <\/p>\n<p>  <em>\u0414\u0430\u0435\u043c \u043c\u0438\u043d\u0443\u0442\u043a\u0443 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043f\u0430\u0443\u0437\u0443 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e&#8230;<\/em><\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h3 id=\"ostorozhno-otvet\">\u041e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u041e\u0442\u0432\u0435\u0442!<\/h3>\n<p>  <\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b. \u0412 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oz\/kt\/he\/ozkthews6vunc4t9mhrkh6-edkk.jpeg\">  <\/p>\n<p>  \u041d\u0430 \u0441\u0430\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e <em>Alexander<\/em> \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043d\u0430 <em>Maxim<\/em>, \u0430 <em>Dmitriy<\/em> \u0438 <em>Anton<\/em>, \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439. \u0410 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043b\u043e\u0433\u0438:<\/p>\n<p>  <\/p>\n<ol>\n<li><em>WILL UNMOUNT Dmitriy<\/em><\/li>\n<li><em>DID UPDATE Alexander<\/em> \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043d\u0430 <em>Maxim<\/em><\/li>\n<li><em>Dmitriy<\/em> \u0441\u043d\u043e\u0432\u0430 \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u0439.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438 \u0432\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u043b\u0438? \u0418 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u0432 \u0447\u0435\u043c \u0431\u044b\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430<\/p>\n<p>  <\/p>\n<h3 id=\"razbor-otveta\">\u0420\u0430\u0437\u0431\u043e\u0440 \u043e\u0442\u0432\u0435\u0442\u0430<\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <em>Anton<\/em>, <em>key<\/em> \u0438 <em>name<\/em> \u0434\u043e \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438, \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 <em>key<\/em> \u0438 <em>name<\/em> \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438, \u0430 \u044f \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e \u0447\u0442\u043e \u0441\u0430\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <strong>User<\/strong> \u044d\u0442\u043e <strong>PureComponent<\/strong>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043e\u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0438 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ej\/nz\/r_\/ejnzr_rsf2g5f1wzcrkblj7feka.jpeg\">  <\/p>\n<p>  \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <em>Alexander<\/em> \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>name<\/em> \u043d\u0430 <em>Maxim<\/em>, \u0430 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 <em>props<\/em> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>componentDidUpdate<\/strong>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u044b \u0438 \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xs\/of\/tn\/xsoftnpyzjjjyn0hw7dpiu4fodc.jpeg\">  <\/p>\n<p>  \u0418 \u0441\u0430\u043c\u044b\u0439 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <em>Dmitriy<\/em>, \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <strong>User<\/strong> \u044d\u0442\u043e <strong>PureComponent<\/strong> \u0438 \u043c\u044b \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0438 <em>name<\/em>, \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <em>Dmitriy<\/em> \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u043b\u0441\u044f \u0438 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u043e\u043d <em>Dmitriy<\/em> \u0441\u043e\u0437\u0434\u0430\u043b\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e. \u041e \u0447\u0435\u043c \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 <em>WILL UNMOUN \u0438 DID MOUNT<\/em>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/06\/j-\/mz\/06j-mzwo2vnwudyvo6xckzdr8v8.jpeg\">  <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0441\u0443\u0442\u044c <em>React key<\/em>. \u0415\u0441\u043b\u0438 <strong>\u0414\u041e<\/strong> \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439, <em>key<\/em> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b, \u0430 <strong>\u041f\u041e\u0421\u041b\u0415<\/strong> \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 <em>key<\/em> \u0438\u0441\u0447\u0435\u0437, \u0442\u043e \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u0447\u0435\u043c\u0443 \u0431\u044b\u043b \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d <em>key<\/em>, \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d. \u0418 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0435\u0441\u043b\u0438 <strong>\u0414\u041e<\/strong> \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 <em>key<\/em> \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b, \u0430 <strong>\u041f\u041e\u0421\u041b\u0415<\/strong> \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 <em>key<\/em> \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f, \u0442\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0441 \u043d\u0443\u043b\u044f. \u0425\u043e\u0442\u044f \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043a\u0430\u043a \u0431\u044b\u043b <em>Dmitriy<\/em> \u0442\u0430\u043a \u043e\u043d \u0438 \u043e\u0441\u0442\u0430\u043b\u0441\u044f, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0438\u0434\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445, \u0438\u043b\u0438 \u043f\u0440\u0438 \u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435<\/p>\n<p>  <\/p>\n<h2 id=\"zadachka-poslozhnee\">\u0417\u0430\u0434\u0430\u0447\u043a\u0430 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435<\/h2>\n<p>  <\/p>\n<p>\u0418\u0434\u0435\u044e \u044f \u0434\u0443\u043c\u0430\u044e \u0432\u044b \u0443\u043b\u043e\u0432\u0438\u043b\u0438, \u043d\u043e \u043b\u044e\u0431\u0443\u044e \u0442\u0435\u043e\u0440\u0438\u044e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438!<\/p>\n<p>  <\/p>\n<h3 id=\"predystoriya\">\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u0432 <em>React<\/em> \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u0431\u044b\u0442\u0443\u0435\u0442 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0440. \u042d\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>index<\/em> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043b\u044e\u0434\u0438 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0434\u0430\u0436\u0435 <em>eslint<\/em> \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>index<\/em> \u0432\u043d\u0443\u0442\u0440\u0438 <em>key<\/em>. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0440\u0435\u0431\u044f\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0438 \u043e\u0441\u043e\u0431\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443 \u043d\u0435 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u044e\u0442.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435, \u044f \u0431\u044b \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u043b, \u0447\u0442\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 <em>React<\/em> \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/o5\/hf\/oe\/o5hfoeploh54s5goeyghnzls8as.jpeg\">  <\/p>\n<p>  \u0410 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<h3 id=\"postanovka-zadachi-1\">\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0432\u0441\u0435 \u0442\u0435\u0445 \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0445 \u0431\u0443\u0434\u0435\u0442 5 \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const users = [{   id: 1,   name: 'Alexander', }, {   id: 2,   name: 'Dmitriy', }, {   id: 3,   name: 'Anton', }, {   id: 4,   name: 'Artem', }, {   id: 5,   name: 'Andrey', }];<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f <em>key<\/em> \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e <em>id<\/em> \u2014 <em>index<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const Users = ({ users }) =&gt; {   return users.map((user) =&gt; {     return (       &lt;User         key={index}         name={user.name}       \/&gt;     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <strong>User<\/strong> \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c 5 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 <em>DID MOUNT<\/em> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435, \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <em>Dmitriy<\/em> \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const users = [{   id: 1,   name: 'Alexander', }\/*, {   id: 2,   name: 'Dmitriy', }*\/, {   id: 3,   name: 'Anton', }, {   id: 4,   name: 'Artem', }, {   id: 5,   name: 'Andrey', }];<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"vopros\">\u0412\u043e\u043f\u0440\u043e\u0441<\/h3>\n<p>  <\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a\u0438\u0435 \u043b\u043e\u0433\u0438 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439?<\/p>\n<p>  \u0421\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0430 \u043f\u0430\u0443\u0437\u0443 \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043d\u0430\u0434 \u043e\u0442\u0432\u0435\u0442\u043e\u043c.<\/p>\n<p>  <\/p>\n<h3 id=\"ostorozhno-otvet-1\">\u041e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u041e\u0442\u0432\u0435\u0442!<\/h3>\n<p>  <\/p>\n<p>\u0418 \u0442\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fl\/na\/ag\/flnaaglx3apo5leabq-padom-tc.jpeg\">  <\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u043b\u043e\u0433 \u0438 \u0441\u0430\u043c\u044b\u0439 \u0441\u043f\u043e\u0440\u043d\u044b\u0439 \u044d\u0442\u043e <em>WILL UNMOUNT Andrey<\/em>, \u0441\u043f\u043e\u0440\u043d\u044b\u0439 \u043e\u043d \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u043c\u044b \u0443\u0434\u0430\u043b\u044f\u043b\u0438 <em>Dmitriy<\/em>, \u0430 \u0443\u0434\u0430\u043b\u0438\u043b\u0441\u044f <em>Andrey<\/em>. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 3 \u043b\u043e\u0433\u0430 \u0443\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044f\u0441\u043d\u044f\u044e\u0442, \u0442\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435. \u041c\u044b \u0432\u0438\u0434\u0438\u043c <em>DID UPDATE<\/em> \u0434\u043b\u044f \u0442\u0440\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<h3 id=\"razbor-otveta-1\">\u0420\u0430\u0437\u0431\u043e\u0440 \u043e\u0442\u0432\u0435\u0442\u0430<\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e. \u0411\u044b\u043b\u043e 5 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0418 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043c\u044b\u0441\u043b\u0438\u0442\u044c \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0442.\u0435. \u043c\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Dmitriy. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/6_\/no\/mx\/6_nomxrkyix7eh3eyk2kvo1zkfk.jpeg\">  <\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0438\u0434\u0438\u0442 <em>React<\/em>. \u0414\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0431\u044b\u043b\u043e 5 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b\u0438 <em>key<\/em>. \u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043b\u043e 4 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u041a\u0430\u0436\u0434\u043e\u043c\u0443 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d <em>key<\/em>. \u0418 <em>react<\/em>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e <em>key<\/em>, \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u0438\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zs\/yq\/g9\/zsyqg9oejl49wchy4_2xn6eq8bg.jpeg\">  <\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u044d\u0442\u0438\u043c \u043a\u043b\u044e\u0447\u0430\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kd\/y9\/he\/kdy9he0pz83jel7vrpiwx-blyta.jpeg\">  <\/p>\n<p>  \u0418 \u0442\u0443\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043b\u043e\u0433\u0438 \u0431\u044b\u043b\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u043c\u0438. \u0412 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0441\u044f <em>Dmitriy<\/em>, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u043e\u0432\u044b\u0439 <em>props<\/em> <em>name<\/em> \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <em>Anton<\/em>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u044b \u0438 \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u043b\u043e\u0433 <em>DID UPDATE<\/em>. \u0422\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0438 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0438 \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 3 \u0440\u0430\u0437\u0430 <em>DID UPDATE<\/em>. \u0410 <em>key<\/em> \u0440\u0430\u0432\u043d\u044b\u0439 5, \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0438 \u0443\u0432\u0438\u0434\u0435\u043b\u0438 <em>WILL UNMOUNT Andrey<\/em>, \u0430 \u043d\u0435 <em>WILL UNMOUNT Dmitriy<\/em>.<\/p>\n<p>  <\/p>\n<h3 id=\"podvedem-itog-zadache\">\u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433 \u0437\u0430\u0434\u0430\u0447\u0435<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <em>id<\/em>, \u0430 \u043d\u0435 <em>index<\/em> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f <em>key<\/em>. \u0412\u0441\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u0438 \u0443 \u043d\u0430\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u043b\u0441\u044f \u0431\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <em>Dmitriy<\/em>, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0431\u044b \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e \u0442\u0430\u043a\u0438\u0435 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u0438 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u043b\u0438 \u043d\u0430\u0441 \u0432 <em>React<\/em> \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438. \u0418 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u044b, \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 <em>drag and drop<\/em>, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"domashka\">\u0414\u043e\u043c\u0430\u0448\u043a\u0430<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0447\u0442\u043e \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0440\u043e\u043b\u0438, \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const users = [{   id: 1,   name: 'Alexander',   role: 'user', }, {   id: 2,   name: 'Dmitriy',   role: 'admin', }, {   id: 3,   name: 'Anton',   role: 'user', }, {   id: 4,   name: 'Artem',   role: 'admin', }, {   id: 5,   name: 'Andrey',   role: 'user', }];<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u043e\u043b\u0438 \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <strong>User<\/strong>, \u0430 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440, \u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <strong>Admin<\/strong>. \u0414\u043b\u044f <em>key<\/em> \u043c\u044b \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <em>index<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const Users = ({ users }) =&gt; {   return users.map((user) =&gt; {     const Component = user.role === 'admin' ? Admin : User;      return (       &lt;Component         key={index}         name={user.name}       \/&gt;     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0441\u043d\u043e\u0432\u0430 \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <em>Dmitriy<\/em>.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u0430\u043a\u0438\u0435 \u043b\u043e\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438? <\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c, \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f\u2026<\/p>\n<p>  <\/p>\n<h3 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0442\u043e\u0433\u0430 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435\u0442. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0412\u0430\u043c \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043e\u0438 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b \u043e\u0442\u043a\u0440\u044b\u043b\u0438 \u0434\u043b\u044f \u0441\u0435\u0431\u044f, \u0447\u0442\u043e \u0442\u043e \u043d\u043e\u0432\u043e\u0435, \u0430 \u0435\u0441\u043b\u0438 \u0412\u0430\u043c \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0438 \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0435\u0449\u0435, \u043b\u043e\u0432\u0438\u0442\u0435 <a href=\"https:\/\/www.youtube.com\/channel\/UClgj-KWiNaOo9H1rz1ISO6Q\" rel=\"nofollow\">\u0441\u0441\u044b\u043b\u043a\u0443<\/a><\/p>\n<\/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=\"https:\/\/habr.com\/ru\/post\/527596\/\"> https:\/\/habr.com\/ru\/post\/527596\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>  <\/p>\n<p>\u042f \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0438 \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f <em>React key<\/em>, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u044f \u0432\u0438\u0436\u0443 \u043d\u0435\u0434\u043e\u0443\u043c\u0435\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0430\u043c\u0435\u043a\u0430\u044e\u0449\u0438\u0439 \u201c\u0414\u0430, \u0442\u0430\u043c \u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u043e\u0434\u0435 \u043d\u0435\u0447\u0435\u0433\u043e?\u201d. \u0415\u0441\u043b\u0438 \u0412\u0430\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f <em>React key<\/em> \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0442\u043e\u0433\u0434\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043c\u0438\u043d\u0438 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 (<a href=\"https:\/\/youtu.be\/OtAlPwW8DNU\" rel=\"nofollow\">\u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u043e\u0439 \u0432\u0438\u0434\u0435\u043e<\/a>)<\/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-312997","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312997","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=312997"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312997\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}