{"id":332625,"date":"2022-04-30T09:00:17","date_gmt":"2022-04-30T09:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=332625"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=332625","title":{"rendered":"<span>Fiber \u0438\u0437\u043d\u0443\u0442\u0440\u0438: \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u043f\u0441\u043e\u0432 \u0432 React<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0430 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b Fiber, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f React \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0440\u043e\u043f\u0441\u043e\u0432 \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<hr\/>\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u0435\u0440\u0438\u0438 (\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434) &#8212; <a href=\"https:\/\/habr.com\/ru\/post\/662549\/\" rel=\"noopener noreferrer nofollow\">Fiber \u0438\u0437\u043d\u0443\u0442\u0440\u0438: \u041f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f React<\/a><\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><a href=\"#f1\" rel=\"noopener noreferrer nofollow\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f2\" rel=\"noopener noreferrer nofollow\">\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f3\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f4\" rel=\"noopener noreferrer nofollow\">beginWork<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f5\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f6\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f7\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f8\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f9\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 span<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f10\" rel=\"noopener noreferrer nofollow\">Effects list (\u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432)<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f11\" rel=\"noopener noreferrer nofollow\">Commit \u0444\u0430\u0437\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f12\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f14\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f DOM<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f15\" rel=\"noopener noreferrer nofollow\">\u0412\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u043e\u0432 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u043c\u0443\u0442\u0430\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p><a class=\"anchor\" name=\"f1\" id=\"f1\"><\/a><\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/662549\/\" rel=\"noopener noreferrer nofollow\">Fiber \u0438\u0437\u043d\u0443\u0442\u0440\u0438: \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f React<\/a>\u00a0\u044f \u0437\u0430\u043b\u043e\u0436\u0438\u043b \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u043f\u0438\u0448\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0422\u0430\u043c \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 fiber-\u0443\u0437\u043b\u044b, \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0438 work in progress \u0434\u0435\u0440\u0435\u0432\u044c\u044f, \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432. \u042f \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0444\u0430\u0437\u0430\u043c\u0438 <code>render<\/code> \u0438 <code>commit<\/code>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 \u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u0430\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043d\u0435\u0435.<\/p>\n<p>\u042f \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b \u0432\u0430\u0441 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c0d\/07d\/415\/c0d07d415e1585e818a118820d4e2f33.gif\" width=\"210\" height=\"68\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c0d\/07d\/415\/c0d07d415e1585e818a118820d4e2f33.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c <a href=\"https:\/\/stackblitz.com\/edit\/react-jwqn64\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0432\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>button<\/code> \u0438 <code>span<\/code> \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render<\/code>. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044e \u0442\u0435\u043a\u0441\u0442\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code>:<\/p>\n<pre><code class=\"javascript\">class ClickCounter extends React.Component {     constructor(props) {         super(props);         this.state = {count: 0};         this.handleClick = this.handleClick.bind(this);     }      handleClick() {         this.setState((state) => {             return {count: state.count + 1};         });     }      componentDidUpdate() {}      render() {         return [             &lt;button key=\"1\" onClick={this.handleClick}>Update counter&lt;\/button>,             &lt;span key=\"2\">{this.state.count}&lt;\/span>         ]     } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043c\u0435\u0442\u043e\u0434 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 <code>componentDidUpdate<\/code> \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a React \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 <a href=\"https:\/\/medium.com\/react-in-depth\/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react-e1c04700ef6e\" rel=\"noopener noreferrer nofollow\">effects<\/a> \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <code>commit<\/code>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c, \u043a\u0430\u043a React \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u0441\u0442\u0440\u043e\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0432 \u0444\u0430\u0437\u0430\u0445 <code>render<\/code> \u0438 <code>commit<\/code>.<\/p>\n<p>\u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u0432 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/cbbc2b6c4d0d8519145560bd8183ecde55168b12\/packages\/react-reconciler\/src\/ReactFiberCompleteWork.js#L532\" rel=\"noopener noreferrer nofollow\">completeWork<\/a> React:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>count<\/code> \u0432 <code>state<\/code> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code><\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>render<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 props \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u043a\u0430\u043a <a href=\"https:\/\/github.com\/facebook\/react\/blob\/95a313ec0b957f71798a69d8e83408f40e76765b\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L523\" rel=\"noopener noreferrer nofollow\">commitRoot<\/a> React:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>textContent<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code><\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 <code>componentDidUpdate<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>setState<\/code> \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u043a\u043b\u0438\u043a\u0430.<\/p>\n<p><strong>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c React. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a React \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438.<\/strong><\/p>\n<p><a class=\"anchor\" name=\"f2\" id=\"f2\"><\/a><\/p>\n<h2>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>click<\/code>, \u0438 React \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043f\u0440\u043e\u043f\u0441\u0435 \u043a\u043d\u043e\u043f\u043a\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">class ClickCounter extends React.Component {     ...     handleClick() {         this.setState((state) => {             return {count: state.count + 1};         });     } }<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 React \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u043d\u0438\u043c <code>updater<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a \u043c\u043e\u0441\u0442 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0438 \u044f\u0434\u0440\u043e\u043c React. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>setState<\/code> \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0432 ReactDOM, React Native, \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 updater \u0432 ReactDOM, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Fiber reconciler. \u0414\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code> \u044d\u0442\u043e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/6938dcaacbffb901df27782b7821836961a5b68d\/packages\/react-reconciler\/src\/ReactFiberClassComponent.js#L186\" rel=\"noopener noreferrer nofollow\">classComponentUpdater<\/a>. \u041e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 Fiber, \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0432\u044f\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043e\u043d\u0438, \u043f\u043e \u0441\u0443\u0442\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 Fiber \u0443\u0437\u043b\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <a href=\"https:\/\/medium.com\/react-in-depth\/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react-e1c04700ef6e\" rel=\"noopener noreferrer nofollow\">Fiber \u0443\u0437\u0435\u043b<\/a>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 <code>ClickCounter<\/code>, \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<pre><code class=\"javascript\">{     stateNode: new ClickCounter,     type: ClickCounter,     updateQueue: {          baseState: {count: 0}          firstUpdate: {              next: {                  payload: (state) => { return {count: state.count + 1} }              }          },          ...      },      ... }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 <code>updateQueue.firstUpdate.next.payload<\/code> &#8212; \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432 <code>setState<\/code> \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <code>ClickCounter<\/code>. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <code>render<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"f3\" id=\"f3\"><\/a><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/h2>\n<p><a href=\"https:\/\/indepth.dev\/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react\/\" rel=\"noopener noreferrer nofollow\">\u0413\u043b\u0430\u0432\u0430 \u043e \u0446\u0438\u043a\u043b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b<\/a> \u0432 \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u0440\u043e\u043b\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>nextUnitOfWork<\/code>. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 fiber-\u0443\u0437\u0435\u043b \u0438\u0437 <code>workInProgress<\/code> \u0434\u0435\u0440\u0435\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u041a\u043e\u0433\u0434\u0430 React \u043e\u0431\u0445\u043e\u0434\u0438\u0442 fiber-\u0434\u0435\u0440\u0435\u0432\u043e, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0435\u0449\u0435 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c fiber-\u0443\u0437\u0435\u043b \u0441 \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>setState<\/code> \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d. React \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0438\u0437 <code>setState<\/code> \u0432 <code>updateQueue<\/code> \u043d\u0430 fiber-\u0443\u0437\u043b\u0435 <code>ClickCounter<\/code> \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443. React \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0444\u0430\u0437\u0443 <code>render<\/code>. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043e\u0431\u0445\u043e\u0434 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e fiber-\u0443\u0437\u043b\u0430 <code>HostRoot<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/95a313ec0b957f71798a69d8e83408f40e76765b\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L1132\" rel=\"noopener noreferrer nofollow\">renderRoot<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u043e\u0431\u0445\u043e\u0434\u0438\u0442 (\u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442) \u0443\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0443\u0437\u043b\u044b Fiber, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442 \u0443\u0437\u0435\u043b \u0441 \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d fiber-\u0443\u0437\u0435\u043b, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0435\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u042d\u0442\u043e fiber-\u0443\u0437\u0435\u043b <code>ClickCounter<\/code>.<\/p>\n<p>\u0412\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043f\u0438\u0438 \u044d\u0442\u043e\u0433\u043e fiber-\u0443\u0437\u043b\u0430, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u0435 <code>alternate<\/code>. \u0415\u0441\u043b\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0443\u0437\u0435\u043b \u0435\u0449\u0435 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043d, React \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043f\u0438\u044e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/769b1f270e1251d9dbdce0fcbd9e92e502d059b8\/packages\/react-reconciler\/src\/ReactFiber.js#L326\" rel=\"noopener noreferrer nofollow\">createWorkInProgress<\/a> \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>nextUnitOfWork<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 fiber-\u0443\u0437\u0435\u043b <code>ClickCounter<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"f4\" id=\"f4\"><\/a><\/p>\n<h2>beginWork<\/h2>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0430\u0448 fiber \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/cbbc2b6c4d0d8519145560bd8183ecde55168b12\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js#L1489\" rel=\"noopener noreferrer nofollow\">beginWork<\/a>.<\/p>\n<blockquote>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e fiber-\u0443\u0437\u043b\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435, \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0442\u043e\u0447\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0442\u043b\u0430\u0434\u0438\u0442\u044c <code>render<\/code> \u0444\u0430\u0437\u0443. \u042f \u0447\u0430\u0441\u0442\u043e \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u044e \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0442\u0438\u043f fiber-\u0443\u0437\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u043d\u0435 \u0443\u0437\u0435\u043b.<\/p>\n<\/blockquote>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>beginWork<\/code> &#8212; \u044d\u0442\u043e, \u043f\u043e \u0441\u0443\u0442\u0438, \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>switch<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0433\u0430 (\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e tag), \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 <code>CountClicks<\/code> \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432\u0437\u044f\u0442\u0430 \u044d\u0442\u0430 \u0432\u0435\u0442\u0432\u044c:<\/p>\n<pre><code class=\"javascript\">function beginWork(current$$1, workInProgress, ...) {     ...     switch (workInProgress.tag) {         ...         case FunctionalComponent: {...}         case ClassComponent:         {             ...             return updateClassComponent(current$$1, workInProgress, ...);         }         case HostComponent: {...}         case ... }<\/code><\/pre>\n<p>\u0438 \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/1034e26fe5e42ba07492a736da7bdf5bf2108bc6\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js#L428\" rel=\"noopener noreferrer nofollow\">updateClassComponent<\/a>. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u043b\u0438 React \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c, React \u043b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e:<\/p>\n<pre><code class=\"javascript\">function updateClassComponent(current, workInProgress, Component, ...) {     ...     const instance = workInProgress.stateNode;     let shouldUpdate;     if (instance === null) {         ...         \/\/ \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440         constructClassInstance(workInProgress, Component, ...);         mountClassInstance(workInProgress, Component, ...);         shouldUpdate = true;     } else if (current === null) {         \/\/ \u041f\u0440\u0438 \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e         shouldUpdate = resumeMountClassInstance(workInProgress, Component, ...);     } else {         shouldUpdate = updateClassInstance(current, workInProgress, ...);     }     return finishClassComponent(current, workInProgress, Component, shouldUpdate, ...); }<\/code><\/pre>\n<p><a class=\"anchor\" name=\"f5\" id=\"f5\"><\/a><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/h2>\n<p>\u0423 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u0432 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/6938dcaacbffb901df27782b7821836961a5b68d\/packages\/react-reconciler\/src\/ReactFiberClassComponent.js#L976\" rel=\"noopener noreferrer nofollow\">updateClassInstance<\/a>. \u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c React \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0412\u043e\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u0430 <code>UNSAFE_componentWillReceiveProps()<\/code> (\u0443\u0441\u0442\u0430\u0440\u0435\u043b)<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 <code>updateQueue<\/code> \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u043e\u0432 <code>getDerivedStateFromProps<\/code> \u0441 \u044d\u0442\u0438\u043c \u043d\u043e\u0432\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u043e\u0432 <code>shouldComponentUpdate<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0445\u043e\u0447\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f; \u0435\u0441\u043b\u0438 <code>false<\/code>, \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u044b\u0437\u043e\u0432 <code>render<\/code> \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0438 \u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432; \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u043e\u0432 <code>UNSAFE_componentWillUpdate<\/code> (\u0443\u0441\u0442\u0430\u0440\u0435\u043b)<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0445\u0443\u043a\u0430 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 <code>componentDidUpdate<\/code><\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0425\u043e\u0442\u044f \u044d\u0444\u0444\u0435\u043a\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 <code>componentDidUpdate<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 <code>render<\/code> \u0444\u0430\u0437\u0435, \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 <code>commit<\/code> \u0444\u0430\u0437\u0435.<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 <code>state<\/code> \u0438 <code>props<\/code> \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<p><code>state<\/code> \u0438 <code>props<\/code> \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b\u0432\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render<\/code> \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 <code>state<\/code> \u0438 <code>props<\/code>. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437.<\/p>\n<p>\u0412\u043e\u0442 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">function updateClassInstance(current, workInProgress, ctor, newProps, ...) {     const instance = workInProgress.stateNode;     const oldProps = workInProgress.memoizedProps;     instance.props = oldProps;     if (oldProps !== newProps) {         callComponentWillReceiveProps(workInProgress, instance, newProps, ...);     }      let updateQueue = workInProgress.updateQueue;     if (updateQueue !== null) {         processUpdateQueue(workInProgress, updateQueue, ...);         newState = workInProgress.memoizedState;     }      applyDerivedStateFromProps(workInProgress, ...);     newState = workInProgress.memoizedState;      const shouldUpdate = checkShouldComponentUpdate(workInProgress, ctor, ...);     if (shouldUpdate) {         instance.componentWillUpdate(newProps, newState, nextContext);         workInProgress.effectTag |= Update;         workInProgress.effectTag |= Snapshot;     }      instance.props = newProps;     instance.state = newState;      return shouldUpdate; }<\/code><\/pre>\n<p>\u042f \u0443\u0434\u0430\u043b\u0438\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, React \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043c\u0435\u0442\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>typeof<\/code>. \u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a React \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>componentDidUpdate<\/code> \u043f\u0435\u0440\u0435\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">if (typeof instance.componentDidUpdate === 'function') {     workInProgress.effectTag |= Update; }<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code> \u043d\u0430 render \u0444\u0430\u0437\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 fiber-\u0443\u0437\u043b\u0430\u0445. \u041a\u043e\u0433\u0434\u0430 React \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, fiber-\u0443\u0437\u0435\u043b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">{     effectTag: 0,     elementType: class ClickCounter,     firstEffect: null,     memoizedState: {count: 0},     type: class ClickCounter,     stateNode: {         state: {count: 0}     },     updateQueue: {         baseState: {count: 0},         firstUpdate: {             next: {                 payload: (state, props) => {\u2026}             }         },         ...     } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c fiber-\u0443\u0437\u0435\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">{     effectTag: 4,     elementType: class ClickCounter,     firstEffect: null,     memoizedState: {count: 1},     type: class ClickCounter,     stateNode: {         state: {count: 1}     },     updateQueue: {         baseState: {count: 1},         firstUpdate: null,         ...     } }<\/code><\/pre>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/em>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>count<\/code> \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 <code>1<\/code> \u0432 <code>memoizedState<\/code> \u0438 <code>baseState<\/code> \u0432 <code>updateQueue<\/code>. React \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u043b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code>.<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043d\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>firstUpdate<\/code> \u0440\u0430\u0432\u043d\u043e <code>null<\/code>. \u0418 \u0447\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 <code>effectTag<\/code>. \u041e\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 <code>0<\/code>, \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>4<\/code>. \u0412 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u044d\u0442\u043e <code>100<\/code>, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0442\u0440\u0435\u0442\u0438\u0439 \u0431\u0438\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0438\u0442\u043e\u043c \u0434\u043b\u044f <code>Update<\/code> <a href=\"https:\/\/github.com\/facebook\/react\/blob\/b87aabdfe1b7461e7331abb3601d9e6bb27544bc\/packages\/shared\/ReactSideEffectTags.js\" rel=\"noopener noreferrer nofollow\">side-effect tag<\/a>:<\/p>\n<pre><code class=\"javascript\">export const Update = 0b00000000100;<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u0432 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c fiber-\u0443\u0437\u043b\u043e\u043c <code>ClickCounter<\/code>, React \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u0435\u043c\u0443\u0442\u0430\u0446\u0438\u0438, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b.<\/p>\n<p><a class=\"anchor\" name=\"f6\" id=\"f6\"><\/a><\/p>\n<h2>\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e React \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043a <a href=\"https:\/\/github.com\/facebook\/react\/blob\/340bfd9393e8173adca5380e6587e1ea1a23cefa\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js#L355\" rel=\"noopener noreferrer nofollow\">finishClassComponent<\/a>. \u0417\u0434\u0435\u0441\u044c React \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>render<\/code> \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u0438\u0444\u0444\u0438\u043d\u0433\u0430 (\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f) \u043a \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c. \u0412\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u043e\u043f\u0438\u0441\u0430\u043d <a href=\"https:\/\/reactjs.org\/docs\/reconciliation.html#the-diffing-algorithm\" rel=\"noopener noreferrer nofollow\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>. \u0412\u043e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0447\u0430\u0441\u0442\u044c:<\/p>\n<blockquote>\n<p>\u041f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 React DOM \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, React \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043e\u0431\u043e\u0438\u0445, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0443\u0437\u0435\u043b DOM \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b.<\/p>\n<\/blockquote>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043a\u043e\u043f\u043d\u0443\u0442\u044c \u0433\u043b\u0443\u0431\u0436\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f fiber-\u0443\u0437\u043b\u044b \u0441 React-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u041d\u043e \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439. \u042f \u043d\u0430\u043f\u0438\u0448\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u0442\u0435\u0440\u043f\u0438\u0442\u0441\u044f \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 reconcileChildrenArray, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434 <code>render<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 React \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/blockquote>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0449\u0438.\u00a0<strong>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445<\/strong>, \u043a\u043e\u0433\u0434\u0430 React \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, <strong>\u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0443\u0437\u043b\u044b Fiber \u0434\u043b\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 React<\/strong>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0445 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render<\/code>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>finishClassComponent<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0435\u0431\u0435\u043d\u043a\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 Fiber. \u041e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0430 <code>nextUnitOfWork<\/code> \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u043f\u043e\u0437\u0436\u0435 \u0432 \u0446\u0438\u043a\u043b\u0435 \u0440\u0430\u0431\u043e\u0442.\u00a0<strong>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445<\/strong>, React <strong>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u043f\u0441\u044b \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432<\/strong> \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439 \u0434\u043b\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 React, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render<\/code>.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 fiber-\u0443\u0437\u0435\u043b, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 <code>span<\/code>, \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a React \u0432\u044b\u0432\u0435\u0440\u0438\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 <code>ClickCounter<\/code>:<\/p>\n<pre><code class=\"javascript\">{     stateNode: new HTMLSpanElement,     type: \"span\",     key: \"2\",     memoizedProps: {children: 0},     pendingProps: {children: 0},     ... }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>children<\/code> \u0432 \u043e\u0431\u043e\u0438\u0445 <code>memoizedProps<\/code> \u0438 <code>pendingProps<\/code> \u0440\u0430\u0432\u043d\u043e <code>0<\/code>. \u0412\u043e\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 React, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0438\u0437 <code>render<\/code> \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code>:<\/p>\n<pre><code class=\"javascript\">{     $$typeof: Symbol(react.element)     key: \"2\"     props: {children: 1}     ref: null     type: \"span\" }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, <strong>\u0435\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438<\/strong> \u0432 fiber-\u0443\u0437\u043b\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c React-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c. \u0412\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/769b1f270e1251d9dbdce0fcbd9e92e502d059b8\/packages\/react-reconciler\/src\/ReactFiber.js#L326\" rel=\"noopener noreferrer nofollow\"><strong>createWorkInProgress<\/strong><\/a><strong>`<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 fiber-\u0443\u0437\u043b\u043e\u0432, <strong>React \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 React \u0432 fiber-\u0443\u0437\u0435\u043b<\/strong>.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a React \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442 \u0441\u0432\u0435\u0440\u043a\u0443 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code>, fiber-\u0443\u0437\u0435\u043b <code>span<\/code> \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 <code>pendingProps<\/code>. \u041e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 <code>span<\/code> React:<\/p>\n<pre><code class=\"javascript\">{     stateNode: new HTMLSpanElement,     type: \"span\",     key: \"2\",     memoizedProps: {children: 0},     pendingProps: {children: 1},     ... }<\/code><\/pre>\n<p>\u041f\u043e\u0437\u0436\u0435, \u043a\u043e\u0433\u0434\u0430 React \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 <code>span<\/code>, \u043e\u043d \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 <code>memoizedProps<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f DOM.<\/p>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e React \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 <code>ClickCounter<\/code> \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 render. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043d\u043e\u043f\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c <code>ClickCounter<\/code>, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>nextUnitOfWork<\/code>. \u0421 \u043d\u0435\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 React \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u0442 \u043a \u0435\u0435 \u0441\u0438\u0431\u043b\u0438\u043d\u0433\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f fiber-\u0443\u0437\u0435\u043b <code>span<\/code>. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 <a href=\"https:\/\/medium.com\/react-in-depth\/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react-e1c04700ef6e\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c<\/a>, \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>completeUnitOfWork<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"f7\" id=\"f7\"><\/a><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 span<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>nextUnitOfWork<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 fiber-\u0443\u0437\u043b\u0430 <code>span<\/code>, \u0438 React \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 \u043d\u0438\u043c. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0448\u0430\u0433\u0430\u043c, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c \u0434\u043b\u044f <code>ClickCounter<\/code>, \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/cbbc2b6c4d0d8519145560bd8183ecde55168b12\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js#L1489\" rel=\"noopener noreferrer nofollow\">beginWork<\/a>.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u0448 \u0443\u0437\u0435\u043b <code>span<\/code> \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>HostComponent<\/code>, \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435 switch React \u0431\u0435\u0440\u0435\u0442 \u044d\u0442\u0443 \u0432\u0435\u0442\u0432\u044c:<\/p>\n<pre><code class=\"javascript\">function beginWork(current$$1, workInProgress, ...) {     ...     switch (workInProgress.tag) {         case FunctionalComponent: {...}         case ClassComponent: {...}         case HostComponent:           return updateHostComponent(current, workInProgress, ...);         case ... }<\/code><\/pre>\n<p>\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/cbbc2b6c4d0d8519145560bd8183ecde55168b12\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js#L686\" rel=\"noopener noreferrer nofollow\">updateHostComponent<\/a>. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>updateClassComponent<\/code>, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430. \u0414\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 <code>updateFunctionComponent<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/1034e26fe5e42ba07492a736da7bdf5bf2108bc6\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js\" rel=\"noopener noreferrer nofollow\">ReactFiberBeginWork.js<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"f8\" id=\"f8\"><\/a><\/p>\n<h2>\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 span<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 <code>span<\/code> \u0432 <code>updateHostComponent<\/code> \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0432\u0430\u0436\u043d\u043e\u0433\u043e.<\/p>\n<p><a class=\"anchor\" name=\"f9\" id=\"f9\"><\/a><\/p>\n<h2>\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 span<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f <code>beginWork<\/code> \u0443\u0437\u0435\u043b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>completeWork<\/code>. \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c React \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c <code>memoizedProps<\/code> \u043d\u0430 fiber-\u0443\u0437\u043b\u0435 span. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code>, React \u043e\u0431\u043d\u043e\u0432\u0438\u043b <code>pendingProps<\/code> \u0443 fiber-\u0443\u0437\u043b\u0430 <code>span<\/code>:<\/p>\n<pre><code class=\"javascript\">{     stateNode: new HTMLSpanElement,     type: \"span\",     key: \"2\",     memoizedProps: {children: 0},     pendingProps: {children: 1},     ... }<\/code><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e <code>beginWork<\/code> \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 <code>span<\/code>, React \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 <code>pendingProps<\/code> \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f <code>memoizedProps<\/code>:<\/p>\n<pre><code class=\"javascript\">function performUnitOfWork(workInProgress) {     ...     next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);     workInProgress.memoizedProps = workInProgress.pendingProps;     ... }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>completeWork<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e \u0441\u0443\u0442\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c <code>switch<\/code>, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u0442\u043e\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0432 <code>beginWork<\/code>:<\/p>\n<pre><code class=\"javascript\">function completeWork(current, workInProgress, ...) {     ...     switch (workInProgress.tag) {         case FunctionComponent: {...}         case ClassComponent: {...}         case HostComponent: {             ...             updateHostComponent(current, workInProgress, ...);         }         case ...     } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u0448 fiber-\u0443\u0437\u0435\u043b <code>span<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>HostComponent<\/code>, \u043e\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/cbbc2b6c4d0d8519145560bd8183ecde55168b12\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js#L686\" rel=\"noopener noreferrer nofollow\">updateHostComponent<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 React \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f DOM<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 <code>updateQueue<\/code> fiber-\u0443\u0437\u043b\u0430 <code>span<\/code><\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f DOM<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 fiber-\u0443\u0437\u0435\u043b <code>span<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">{     stateNode: new HTMLSpanElement,     type: \"span\",     effectTag: 0     updateQueue: null     ... }<\/code><\/pre>\n<p>\u0438 \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430, \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">{     stateNode: new HTMLSpanElement,     type: \"span\",     effectTag: 4,     updateQueue: [\"children\", \"1\"],     ... }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u043f\u043e\u043b\u044f\u0445 <code>effectTag<\/code> \u0438 <code>updateQueue<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043d\u0435 <code>0<\/code>, \u0430 <code>4<\/code>. \u0412 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u044d\u0442\u043e <code>100<\/code>, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0442\u0440\u0435\u0442\u0438\u0439 \u0431\u0438\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0438\u0442\u043e\u043c \u0434\u043b\u044f \u0442\u0435\u0433\u0430 \u043f\u043e\u0431\u043e\u0447\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 <code>Update<\/code>. \u042d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e React \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0430\u0437\u044b commit. \u0412 \u043f\u043e\u043b\u0435 <code>updateQueue<\/code> \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e React \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>ClickCounter<\/code> \u0438 \u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0443\u0437\u043b\u044b, \u043e\u043d \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0444\u0430\u0437\u0443 <code>render<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <code>finishedWork<\/code> \u0443 <code>FiberRoot<\/code>. \u042d\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d. \u041e\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0444\u0430\u0437\u044b <code>render<\/code> \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u043f\u043e\u0437\u0436\u0435, \u043a\u043e\u0433\u0434\u0430 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442 React \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p><a class=\"anchor\" name=\"f10\" id=\"f10\"><\/a><\/p>\n<h2>Effects list (\u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432)<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443\u0437\u0435\u043b <code>span<\/code> \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>ClickCounter<\/code> \u0438\u043c\u0435\u044e\u0442 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b, React \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 fiber-\u0443\u0437\u0435\u043b <code>span<\/code> \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>firstEffect<\/code> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>HostFiber<\/code>.<\/p>\n<p>React \u0441\u0442\u0440\u043e\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/d5e1bf07d086e4fc1998653331adecddcd0f5274\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L999\" rel=\"noopener noreferrer nofollow\">compliteUnitOfWork<\/a>. \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u0435\u0440\u0435\u0432\u043e Fiber \u0441 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0443\u0437\u043b\u0430 <code>span<\/code> \u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u0445\u0443\u043a\u043e\u0432 \u043d\u0430 <code>ClickCounter<\/code>:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/99b\/e49\/bfa\/99be49bfa225ef9e8783e2d90a55483f.png\" width=\"460\" height=\"271\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/99b\/e49\/bfa\/99be49bfa225ef9e8783e2d90a55483f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0437\u043b\u043e\u0432 \u0441 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/03e\/872\/be8\/03e872be817c7689771cafed6ddf97eb.png\" width=\"529\" height=\"94\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/03e\/872\/be8\/03e872be817c7689771cafed6ddf97eb.png\"\/><figcaption><\/figcaption><\/figure>\n<p><a class=\"anchor\" name=\"f11\" id=\"f11\"><\/a><\/p>\n<h2>Commit \u0444\u0430\u0437\u0430<\/h2>\n<p>\u042d\u0442\u0430 \u0444\u0430\u0437\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/95a313ec0b957f71798a69d8e83408f40e76765b\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L2306\" rel=\"noopener noreferrer nofollow\">completeRoot<\/a>. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0440\u0430\u0431\u043e\u0442\u0435, \u043e\u043d\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>finishedWork<\/code> \u0434\u043b\u044f <code>FiberRoot<\/code> \u0432 <code>null<\/code>:<\/p>\n<pre><code class=\"javascript\">root.finishedWork = null;<\/code><\/pre>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0439 \u0444\u0430\u0437\u044b <code>render<\/code>, \u0444\u0430\u0437\u0430 <code>commit<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c <code>HostRoot<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u043e \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c.<\/p>\n<p>\u041d\u0430 \u0444\u0430\u0437\u0435 <code>commit<\/code> React \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 DOM \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u043e\u0441\u0442\u043c\u0443\u0442\u0430\u0446\u0438\u0438 <code>componentDidUpdate<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0444\u0430\u0437\u044b <code>render<\/code>, \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u0445.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0437\u0435 <code>render<\/code> \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 <code>span<\/code> \u0438 <code>ClickCounter<\/code>:<\/p>\n<pre><code class=\"javascript\">{ type: ClickCounter, effectTag: 5 } { type: 'span', effectTag: 4 }<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0434\u043b\u044f <code>ClickCounter<\/code> \u0440\u0430\u0432\u043d\u043e <code>5<\/code> **** \u0438\u043b\u0438 <code>101<\/code> \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 <code>Update<\/code> , \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 <code>componentDidUpdate<\/code> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0437\u043d\u0430\u0447\u0430\u0449\u0438\u0439 \u0431\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0431\u044b\u043b\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e fiber-\u0443\u0437\u043b\u0430 \u0432 \u0444\u0430\u0437\u0435 <code>render<\/code>.<\/p>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0434\u043b\u044f <code>span<\/code> \u0440\u0430\u0432\u043d\u043e <code>4<\/code> \u0438\u043b\u0438 <code>100<\/code> \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 <code>update<\/code> \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f DOM \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0443\u0437\u043b\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code>, React \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c <code>textContent<\/code> \u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p><a class=\"anchor\" name=\"f12\" id=\"f12\"><\/a><\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a React \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u044d\u0442\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u044b. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/facebook\/react\/blob\/95a313ec0b957f71798a69d8e83408f40e76765b\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L523\" rel=\"noopener noreferrer nofollow\">commitRoot<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 3 \u043f\u043e\u0434\u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<pre><code class=\"javascript\">function commitRoot(root, finishedWork) {     commitBeforeMutationLifecycles()     commitAllHostEffects();     root.current = finishedWork;     commitAllLifeCycles(); }<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u043e\u0434\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0446\u0438\u043a\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0438\u0445 \u0442\u0438\u043f\u044b. \u041a\u043e\u0433\u0434\u0430 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u044d\u0444\u0444\u0435\u043a\u0442, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0439\u0441\u044f \u043a \u0446\u0435\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0435\u0433\u043e. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 <code>componentDidUpdate<\/code> \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code> \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442 \u0442\u0435\u043a\u0441\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/facebook\/react\/blob\/fefa1269e2a67fa5ef0992d5cc1d6114b7948b7e\/packages\/react-reconciler\/src\/ReactFiberCommitWork.js#L183\" rel=\"noopener noreferrer nofollow\">commitBeforeMutationLifeCycles<\/a> \u0438\u0449\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/b87aabdfe1b7461e7331abb3601d9e6bb27544bc\/packages\/shared\/ReactSideEffectTags.js#L25\" rel=\"noopener noreferrer nofollow\">Snapshot<\/a> \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>getSnapshotBeforeUpdate<\/code>. \u041d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <code>ClickCounter<\/code>, React \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u044d\u0444\u0444\u0435\u043a\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <code>render<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442.<\/p>\n<p><a class=\"anchor\" name=\"f14\" id=\"f14\"><\/a><\/p>\n<h2>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f DOM<\/h2>\n<p>\u0414\u0430\u043b\u0435\u0435 React \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/95a313ec0b957f71798a69d8e83408f40e76765b\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L376\" rel=\"noopener noreferrer nofollow\">commitAllHostEffects<\/a>. \u0417\u0434\u0435\u0441\u044c React \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 <code>span<\/code> \u0441 <code>0<\/code> \u043d\u0430 <code>1<\/code>. \u0414\u043b\u044f fiber-\u0443\u0437\u043b\u0430 <code>ClickCounter<\/code> \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443\u0437\u043b\u044b, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c, \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 DOM.<\/p>\n<p>\u0421\u0443\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0438\u043f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 <code>span<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u0432\u0435\u0442\u0432\u044c <code>Update<\/code>:<\/p>\n<pre><code class=\"javascript\">function updateHostEffects() {     switch (primaryEffectTag) {       case Placement: {...}       case PlacementAndUpdate: {...}       case Update:         {           var current = nextEffect.alternate;           commitWork(current, nextEffect);           break;         }       case Deletion: {...}     } }<\/code><\/pre>\n<p>\u0421\u043f\u0443\u0441\u0442\u0438\u0432\u0448\u0438\u0441\u044c \u0432 <code>commitWork<\/code>, \u043c\u044b \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043f\u0430\u0434\u0435\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/8a8d973d3cc5623676a84f87af66ef9259c3937c\/packages\/react-dom\/src\/client\/ReactDOMComponent.js#L326\" rel=\"noopener noreferrer nofollow\">updateDOMProperties<\/a>. \u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 <code>updateQueue<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <code>render<\/code> \u043a \u0443\u0437\u043b\u0443 Fiber, \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>textContent<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code>:<\/p>\n<pre><code class=\"javascript\">function updateDOMProperties(domElement, updatePayload, ...) {   for (let i = 0; i &lt; updatePayload.length; i += 2) {     const propKey = updatePayload[i];     const propValue = updatePayload[i + 1];     if (propKey === STYLE) { ...}     else if (propKey === DANGEROUSLY_SET_INNER_HTML) {...}     else if (propKey === CHILDREN) {       setTextContent(domElement, propValue);     } else {...}   } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 DOM, React \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u0434\u0435\u0440\u0435\u0432\u043e <code>finishedWork<\/code> \u0432 <code>HostRoot<\/code>. \u042d\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e:<\/p>\n<pre><code class=\"javascript\">root.current = finishedWork;<\/code><\/pre>\n<p><a class=\"anchor\" name=\"f15\" id=\"f15\"><\/a><\/p>\n<h2>\u0412\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u043e\u0432 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u043c\u0443\u0442\u0430\u0446\u0438\u0438<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0430\u044f\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f &#8212; <a href=\"https:\/\/github.com\/facebook\/react\/blob\/d5e1bf07d086e4fc1998653331adecddcd0f5274\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L479\" rel=\"noopener noreferrer nofollow\"><strong>commitAllLifecycles<\/strong><\/a>. \u0417\u0434\u0435\u0441\u044c React \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u043c\u0443\u0442\u0430\u0446\u0438\u0438. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0444\u0430\u0437\u044b <code>render<\/code> React \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u044d\u0444\u0444\u0435\u043a\u0442 <code>Update<\/code> \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 <code>ClickCounter<\/code>. \u042d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0449\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>commitAllLifecycles<\/code> \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>componentDidUpdate<\/code>:<\/p>\n<pre><code class=\"javascript\">function commitAllLifeCycles(finishedRoot, ...) {     while (nextEffect !== null) {         const effectTag = nextEffect.effectTag;         if (effectTag &amp;amp; (Update | Callback)) {             const current = nextEffect.alternate;             commitLifeCycles(finishedRoot, current, nextEffect, ...);         }          if (effectTag &amp;amp; Ref) {             commitAttachRef(nextEffect);         }          nextEffect = nextEffect.nextEffect;     } }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 <a href=\"https:\/\/reactjs.org\/docs\/refs-and-the-dom.html\" rel=\"noopener noreferrer nofollow\">refs<\/a>, \u043d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0438\u0445 \u043d\u0435\u0442, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/e58ecda9a2381735f2c326ee99a1ffa6486321ab\/packages\/react-reconciler\/src\/ReactFiberCommitWork.js#L351\" rel=\"noopener noreferrer nofollow\">commitLifeCycles<\/a>:<\/p>\n<pre><code class=\"javascript\">function commitLifeCycles(finishedRoot, current, ...) {   ...   switch (finishedWork.tag) {     case FunctionComponent: {...}     case ClassComponent: {       const instance = finishedWork.stateNode;       if (finishedWork.effectTag &amp; Update) {         if (current === null) {           instance.componentDidMount();         } else {           ...           instance.componentDidUpdate(prevProps, prevState, ...);         }       }     }     case HostComponent: {...}     case ... }<\/code><\/pre>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 React \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>componentDidMount<\/code> \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u044b \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437.<\/p>\n<hr\/>\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u0435\u0440\u0438\u0438 (\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434) &#8212; <a href=\"https:\/\/habr.com\/ru\/post\/662549\/\" rel=\"noopener noreferrer nofollow\">Fiber \u0438\u0437\u043d\u0443\u0442\u0440\u0438: \u041f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f React<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><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:\/\/habr.com\/ru\/post\/663792\/\"> https:\/\/habr.com\/ru\/post\/663792\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0430 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b Fiber, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f React \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0440\u043e\u043f\u0441\u043e\u0432 \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<hr\/>\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u0435\u0440\u0438\u0438 (\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434) &#8212; <a href=\"https:\/\/habr.com\/ru\/post\/662549\/\" rel=\"noopener noreferrer nofollow\">Fiber \u0438\u0437\u043d\u0443\u0442\u0440\u0438: \u041f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f React<\/a><\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><a href=\"#f1\" rel=\"noopener noreferrer nofollow\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f2\" rel=\"noopener noreferrer nofollow\">\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f3\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f4\" rel=\"noopener noreferrer nofollow\">beginWork<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f5\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f6\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f7\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f8\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f9\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 span<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f10\" rel=\"noopener noreferrer nofollow\">Effects list (\u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432)<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f11\" rel=\"noopener noreferrer nofollow\">Commit \u0444\u0430\u0437\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f12\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f14\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f DOM<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#f15\" rel=\"noopener noreferrer nofollow\">\u0412\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u043e\u0432 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u043c\u0443\u0442\u0430\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p><a class=\"anchor\" name=\"f1\" id=\"f1\"><\/a><\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/662549\/\" rel=\"noopener noreferrer nofollow\">Fiber \u0438\u0437\u043d\u0443\u0442\u0440\u0438: \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f React<\/a>\u00a0\u044f \u0437\u0430\u043b\u043e\u0436\u0438\u043b \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u043f\u0438\u0448\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0422\u0430\u043c \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 fiber-\u0443\u0437\u043b\u044b, \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0438 work in progress \u0434\u0435\u0440\u0435\u0432\u044c\u044f, \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432. \u042f \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0444\u0430\u0437\u0430\u043c\u0438 <code>render<\/code> \u0438 <code>commit<\/code>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 \u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u0430\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043d\u0435\u0435.<\/p>\n<p>\u042f \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b \u0432\u0430\u0441 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c <a href=\"https:\/\/stackblitz.com\/edit\/react-jwqn64\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0432\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>button<\/code> \u0438 <code>span<\/code> \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render<\/code>. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044e \u0442\u0435\u043a\u0441\u0442\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code>:<\/p>\n<pre><code class=\"javascript\">class ClickCounter extends React.Component {     constructor(props) {         super(props);         this.state = {count: 0};         this.handleClick = this.handleClick.bind(this);     }      handleClick() {         this.setState((state) => {             return {count: state.count + 1};         });     }      componentDidUpdate() {}      render() {         return [             &lt;button key=\"1\" onClick={this.handleClick}>Update counter&lt;\/button>,             &lt;span key=\"2\">{this.state.count}&lt;\/span>         ]     } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043c\u0435\u0442\u043e\u0434 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 <code>componentDidUpdate<\/code> \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a React \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 <a href=\"https:\/\/medium.com\/react-in-depth\/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react-e1c04700ef6e\" rel=\"noopener noreferrer nofollow\">effects<\/a> \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <code>commit<\/code>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c, \u043a\u0430\u043a React \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u0441\u0442\u0440\u043e\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0432 \u0444\u0430\u0437\u0430\u0445 <code>render<\/code> \u0438 <code>commit<\/code>.<\/p>\n<p>\u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u0432 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/cbbc2b6c4d0d8519145560bd8183ecde55168b12\/packages\/react-reconciler\/src\/ReactFiberCompleteWork.js#L532\" rel=\"noopener noreferrer nofollow\">completeWork<\/a> React:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>count<\/code> \u0432 <code>state<\/code> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code><\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>render<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 props \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u043a\u0430\u043a <a href=\"https:\/\/github.com\/facebook\/react\/blob\/95a313ec0b957f71798a69d8e83408f40e76765b\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L523\" rel=\"noopener noreferrer nofollow\">commitRoot<\/a> React:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>textContent<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>span<\/code><\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 <code>componentDidUpdate<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>setState<\/code> \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u043a\u043b\u0438\u043a\u0430.<\/p>\n<p><strong>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c React. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a React \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438.<\/strong><\/p>\n<p><a class=\"anchor\" name=\"f2\" id=\"f2\"><\/a><\/p>\n<h2>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>click<\/code>, \u0438 React \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043f\u0440\u043e\u043f\u0441\u0435 \u043a\u043d\u043e\u043f\u043a\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">class ClickCounter extends React.Component {     ...     handleClick() {         this.setState((state) => {             return {count: state.count + 1};         });     } }<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 React \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u043d\u0438\u043c <code>updater<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a \u043c\u043e\u0441\u0442 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0438 \u044f\u0434\u0440\u043e\u043c React. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>setState<\/code> \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0432 ReactDOM, React Native, \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 updater \u0432 ReactDOM, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Fiber reconciler. \u0414\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code> \u044d\u0442\u043e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/6938dcaacbffb901df27782b7821836961a5b68d\/packages\/react-reconciler\/src\/ReactFiberClassComponent.js#L186\" rel=\"noopener noreferrer nofollow\">classComponentUpdater<\/a>. \u041e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 Fiber, \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0432\u044f\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043e\u043d\u0438, \u043f\u043e \u0441\u0443\u0442\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 Fiber \u0443\u0437\u043b\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <a href=\"https:\/\/medium.com\/react-in-depth\/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react-e1c04700ef6e\" rel=\"noopener noreferrer nofollow\">Fiber \u0443\u0437\u0435\u043b<\/a>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 <code>ClickCounter<\/code>, \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<pre><code class=\"javascript\">{     stateNode: new ClickCounter,     type: ClickCounter,     updateQueue: {          baseState: {count: 0}          firstUpdate: {              next: {                  payload: (state) => { return {count: state.count + 1} }              }          },          ...      },      ... }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 <code>updateQueue.firstUpdate.next.payload<\/code> &#8212; \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432 <code>setState<\/code> \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <code>ClickCounter<\/code>. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 <code>render<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"f3\" id=\"f3\"><\/a><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/h2>\n<p><a href=\"https:\/\/indepth.dev\/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react\/\" rel=\"noopener noreferrer nofollow\">\u0413\u043b\u0430\u0432\u0430 \u043e \u0446\u0438\u043a\u043b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b<\/a> \u0432 \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u0440\u043e\u043b\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>nextUnitOfWork<\/code>. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 fiber-\u0443\u0437\u0435\u043b \u0438\u0437 <code>workInProgress<\/code> \u0434\u0435\u0440\u0435\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u041a\u043e\u0433\u0434\u0430 React \u043e\u0431\u0445\u043e\u0434\u0438\u0442 fiber-\u0434\u0435\u0440\u0435\u0432\u043e, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0435\u0449\u0435 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c fiber-\u0443\u0437\u0435\u043b \u0441 \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>setState<\/code> \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d. React \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0438\u0437 <code>setState<\/code> \u0432 <code>updateQueue<\/code> \u043d\u0430 fiber-\u0443\u0437\u043b\u0435 <code>ClickCounter<\/code> \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443. React \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0444\u0430\u0437\u0443 <code>render<\/code>. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043e\u0431\u0445\u043e\u0434 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e fiber-\u0443\u0437\u043b\u0430 <code>HostRoot<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/95a313ec0b957f71798a69d8e83408f40e76765b\/packages\/react-reconciler\/src\/ReactFiberScheduler.js#L1132\" rel=\"noopener noreferrer nofollow\">renderRoot<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u043e\u0431\u0445\u043e\u0434\u0438\u0442 (\u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442) \u0443\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0443\u0437\u043b\u044b Fiber, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442 \u0443\u0437\u0435\u043b \u0441 \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d fiber-\u0443\u0437\u0435\u043b, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0435\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u042d\u0442\u043e fiber-\u0443\u0437\u0435\u043b <code>ClickCounter<\/code>.<\/p>\n<p>\u0412\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043f\u0438\u0438 \u044d\u0442\u043e\u0433\u043e fiber-\u0443\u0437\u043b\u0430, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u0435 <code>alternate<\/code>. \u0415\u0441\u043b\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0443\u0437\u0435\u043b \u0435\u0449\u0435 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043d, React \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043f\u0438\u044e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/769b1f270e1251d9dbdce0fcbd9e92e502d059b8\/packages\/react-reconciler\/src\/ReactFiber.js#L326\" rel=\"noopener noreferrer nofollow\">createWorkInProgress<\/a> \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>nextUnitOfWork<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 fiber-\u0443\u0437\u0435\u043b <code>ClickCounter<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"f4\" id=\"f4\"><\/a><\/p>\n<h2>beginWork<\/h2>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0430\u0448 fiber \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/cbbc2b6c4d0d8519145560bd8183ecde55168b12\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js#L1489\" rel=\"noopener noreferrer nofollow\">beginWork<\/a>.<\/p>\n<blockquote>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e fiber-\u0443\u0437\u043b\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435, \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0442\u043e\u0447\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0442\u043b\u0430\u0434\u0438\u0442\u044c <code>render<\/code> \u0444\u0430\u0437\u0443. \u042f \u0447\u0430\u0441\u0442\u043e \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u044e \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0442\u0438\u043f fiber-\u0443\u0437\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u043d\u0435 \u0443\u0437\u0435\u043b.<\/p>\n<\/blockquote>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>beginWork<\/code> &#8212; \u044d\u0442\u043e, \u043f\u043e \u0441\u0443\u0442\u0438, \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>switch<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u043b\u044f fiber-\u0443\u0437\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0433\u0430 (\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e tag), \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 <code>CountClicks<\/code> \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432\u0437\u044f\u0442\u0430 \u044d\u0442\u0430 \u0432\u0435\u0442\u0432\u044c:<\/p>\n<pre><code class=\"javascript\">function beginWork(current$$1, workInProgress, ...) {     ...     switch (workInProgress.tag) {         ...         case FunctionalComponent: {...}         case ClassComponent:         {             ...             return updateClassComponent(current$$1, workInProgress, ...);         }         case HostComponent: {...}         case ... }<\/code><\/pre>\n<p>\u0438 \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/1034e26fe5e42ba07492a736da7bdf5bf2108bc6\/packages\/react-reconciler\/src\/ReactFiberBeginWork.js#L428\" rel=\"noopener noreferrer nofollow\">updateClassComponent<\/a>. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u043b\u0438 React \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c, React \u043b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e:<\/p>\n<pre><code class=\"javascript\">function updateClassComponent(current, workInProgress, Component, ...) {     ...     const instance = workInProgress.stateNode;     let shouldUpdate;     if (instance === null) {         ...         \/\/ \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440         constructClassInstance(workInProgress, Component, ...);         mountClassInstance(workInProgress, Component, ...);         shouldUpdate = true;     } else if (current === null) {         \/\/ \u041f\u0440\u0438 \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e         shouldUpdate = resumeMountClassInstance(workInProgress, Component, ...);     } else {         shouldUpdate = updateClassInstance(current, workInProgress, ...);     }     return finishClassComponent(current, workInProgress, Component, shouldUpdate, ...); }<\/code><\/pre>\n<p><a class=\"anchor\" name=\"f5\" id=\"f5\"><\/a><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 fiber-\u0443\u0437\u043b\u0430 ClickCounter<\/h2>\n<p>\u0423 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>ClickCounter<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u0432 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/6938dcaacbffb901df27782b7821836961a5b68d\/packages\/react-reconciler\/src\/ReactFiberClassComponent.js#L976\" rel=\"noopener noreferrer nofollow\">updateClassInstance<\/a>. \u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c React \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0412\u043e\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u0430 <code>UNSAFE_componentWillReceiveProps()<\/code> (\u0443\u0441\u0442\u0430\u0440\u0435\u043b)<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 <code>updateQueue<\/code> \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u043e\u0432 <code>getDerivedStateFromProps<\/code> \u0441 \u044d\u0442\u0438\u043c \u043d\u043e\u0432\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u043e\u0432 <code>shouldComponentUpdate<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0445\u043e\u0447\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f; \u0435\u0441\u043b\u0438 <code>false<\/code>, \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u044b\u0437\u043e\u0432 <code>render<\/code> \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0438 \u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432; \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u043e\u0432 <code>UNSAFE_componentWillUpdate<\/code> (\u0443\u0441\u0442\u0430\u0440\u0435\u043b)<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0445\u0443\u043a\u0430 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 <code>componentDidUpdate<\/code><\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0425\u043e\u0442\u044f \u044d\u0444\u0444\u0435\u043a\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 <code>componentDidUpdate<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 <code>render<\/code> \u0444\u0430\u0437\u0435, \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 <code>commit<\/code> \u0444\u0430\u0437\u0435.<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 <code>state<\/code> \u0438 <code>props<\/code> \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<p><code>state<\/code> \u0438 <code>props<\/code> \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b\u0432\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render<\/code> \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 <code>state<\/code> \u0438 <code>props<\/code>. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437.<\/p>\n<p>\u0412\u043e\u0442 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">function updateClassInstance(current, workInProgress, ctor, newProps, ...) {     const instance = workInProgress.stateNode;     const oldProps = workInProgress.memoizedProps;     instance.props = oldProps;     if (oldProps !== newProps) {         callComponentWillReceiveProps(workInProgress, instance, newProps, ...);     }      let updateQueue = workInProgress.updateQueue;     if (updateQueue !== null) {         processUpdateQueue(workInProgress, updateQueue, ...);         newState = workInProgress.memoizedState;     }      applyDerivedStateFromProps(workInProgress, ...);     newState = workInProgress.memoizedState;      const shouldUpdate = checkShouldComponentUpdate(workInProgress,<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-332625","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332625","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=332625"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332625\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}