{"id":316590,"date":"2021-01-19T09:00:59","date_gmt":"2021-01-19T09:00:59","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=316590"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=316590","title":{"rendered":"\u041f\u0435\u0440\u0432\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0445\u0443\u043a\u043e\u0432 (\u0437\u0430\u0434\u0435\u043b \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438)"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u043e\u043d\u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u043b\u043e\u043d\u0433 \u0440\u0438\u0434\u0430\u043c\u0438, \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0445\u0443\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0438 \u043f\u043e\u0442\u043e\u043c \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u0443 (<a href=\"https:\/\/youtu.be\/kcHEWut-DUA\" rel=\"noopener noreferrer nofollow\">\u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u043e\u0439 \u0432\u0438\u0434\u0435\u043e<\/a>).<\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u0445\u0443\u043a\u043e\u0432<\/h2>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <a href=\"https:\/\/github.com\/facebook\/react\" rel=\"noopener noreferrer nofollow\">React-\u0430 \u0432 Github<\/a>. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043c\u043e\u043d\u043e\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0433\u0434\u0435 \u0432\u0441\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043d\u0430\u043c \u043f\u0430\u043a\u0435\u0442\u044b \u043b\u0435\u0436\u0430\u0442 \u0432 <em>packages<\/em>. \u041d\u0438\u0436\u0435 \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0435 \u044f \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/621\/44f\/67c\/62144f67cb2c2d249fb93d97ebe770e1.jpg\" width=\"1231\" height=\"913\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043d\u0435\u0439 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0431\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <em>react-dom<\/em>. \u0418\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <em>render<\/em>, \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 <em>React<\/em> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 <em>HTML<\/em>.<\/p>\n<pre><code class=\"javascript\">import React from \"react\"; import ReactDOM from \"react-dom\";  import App from \".\/App\";  ReactDOM.render(&lt;App \/&gt;, document.getElementById(\"root\"));<\/code><\/pre>\n<p>\u0425\u0443\u043a\u0438 \u0436\u0435 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <em>React<\/em>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 <em>package<\/em> \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u0417\u0430\u0439\u0434\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u0438 \u043e\u0442\u043a\u0440\u043e\u0435\u043c <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/index.js#L48\" rel=\"noopener noreferrer nofollow\">index.js<\/a> \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"javascript\">export {   ...   useCallback,   useContext,   useEffect,   ...   __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,   ... } from '.\/src\/React';<\/code><\/pre>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0445\u0443\u043a\u0438 <code>useCallback<\/code>, <code>useContext<\/code>, <code>useEffect<\/code>. \u0418\u0437 \u0441\u043c\u0435\u0448\u043d\u043e\u0433\u043e, \u043c\u043d\u0435 \u0435\u0449\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f &#171;SECRET INTERNALS DO NOT USE OR YOU WILL BE FIRED&#187;. \u0412\u0438\u0434\u0438\u043c\u043e \u0443 \u043d\u0438\u0445 \u0442\u0430\u043a \u0436\u0435 \u0435\u0441\u0442\u044c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u043e\u043b\u0433, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0449\u0435 \u0438 \u0443\u0432\u043e\u043b\u0438\u0442\u044c \u043c\u043e\u0433\u0443\u0442))) \u042d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0436\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/React.js#L87\" rel=\"noopener noreferrer nofollow\">packages\/react\/src\/React.js<\/a>. \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0442\u043e\u0436\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u043e\u043c \u0445\u0443\u043a\u043e\u0432 \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/ReactHooks.js#L123\" rel=\"noopener noreferrer nofollow\">packages\/react\/src\/ReactHooks.js<\/a>. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0436\u0435 \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u0435 \u043a\u0430\u043a\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0445\u0443\u043a\u043e\u0432:<\/p>\n<pre><code class=\"javascript\">export function useCallback&lt;T&gt;(   callback: T,   deps: Array&lt;mixed&gt; | void | null, ): T {   const dispatcher = resolveDispatcher();   return dispatcher.useCallback(callback, deps); }<\/code><\/pre>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0434\u0435\u0441\u044c <code>useCallback<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>callback<\/code> \u0438 <code>deps<\/code>, \u043d\u043e \u044d\u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u043b\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0432 \u0432\u0438\u0434\u0435 <code>dispatcher<\/code> \u0438 \u0443\u0436\u0435 \u0438\u0437 \u043d\u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u043f\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>useCallback<\/code>.&nbsp; \u0421\u0430\u043c \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/ReactHooks.js#L25\" rel=\"noopener noreferrer nofollow\">resolveDispatcher<\/a> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0432\u0435\u0440\u0445\u0443 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">import ReactCurrentDispatcher from '.\/ReactCurrentDispatcher';  function resolveDispatcher() {   const dispatcher = ReactCurrentDispatcher.current;   invariant(     dispatcher !== null,     'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +       ' one of the following reasons:\\n' +       '1. You might have mismatching versions of React and the renderer (such as React DOM)\\n' +       '2. You might be breaking the Rules of Hooks\\n' +       '3. You might have more than one copy of React in the same app\\n' +       'See https:\/\/reactjs.org\/link\/invalid-hook-call for tips about how to debug and fix this problem.',   );   return dispatcher; }<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e <code>dispatcher<\/code> \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>ReactCurrentDispatcher<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0442\u0441\u044f \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c. \u0410 \u0435\u0441\u043b\u0438 \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b \u043c\u0435\u0442\u043e\u0434 <code>invariant<\/code>, <a href=\"https:\/\/ru.reactjs.org\/docs\/codebase-overview.html#warnings-and-invariants\" rel=\"noopener noreferrer nofollow\">\u0432\u043e\u0442 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442.<\/a> \u0410 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438 \u0444\u0430\u0439\u043b <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/ReactCurrentDispatcher.js#L15\" rel=\"noopener noreferrer nofollow\">packages\/react\/src\/ReactCurrentDispatcher.js<\/a>.<\/p>\n<pre><code class=\"javascript\">import type {Dispatcher} from 'react-reconciler\/src\/ReactInternalTypes';  \/**  * Keeps track of the current dispatcher.  *\/ const ReactCurrentDispatcher = {   \/**    * @internal    * @type {ReactComponent}    *\/   current: (null: null | Dispatcher), };<\/code><\/pre>\n<p>\u0418 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0441 \u0436\u0434\u0435\u0442 \u043b\u0435\u0433\u043a\u043e\u0435 \u0440\u0430\u0437\u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u044d\u0442\u043e\u0442 <code>current<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u044f\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0442\u043e \u0441\u0435\u0442\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043d\u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e. \u041d\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430. \u0422\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0442\u044f\u0442\u0441\u044f \u0432 <code>current<\/code> \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Dispatcher<\/code>. \u0418 \u043e\u043d \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0442\u0441\u044f \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 <em>react-reconcilier<\/em>.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0435\u0440\u0435\u0448\u0435\u043b \u0432 \u043f\u0430\u043a\u0435\u0442 <em>react-reconcilier<\/em> \u0438 \u043f\u043e\u0438\u0441\u043a\u0430\u043b \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043d\u0430\u043c \u0444\u0430\u0439\u043b. \u0418 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L100\" rel=\"noopener noreferrer nofollow\">packages\/react-reconcilier\/src\/ReactFiberHooks.new.js<\/a>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0441\u044f \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>ReactCurrentDispatcher<\/code><\/p>\n<pre><code class=\"javascript\">import ReactSharedInternals from 'shared\/ReactSharedInternals';  const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals;<\/code><\/pre>\n<p>\u042f \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u043b \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>ReactSharedInternals<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>ReactCurrentDispatcher<\/code>. \u0418 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0432 \u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/shared\/ReactSharedInternals.js#L12\" rel=\"noopener noreferrer nofollow\">packages\/shared\/ReactSharedInternals.js<\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 :<\/p>\n<pre><code class=\"javascript\">import * as React from 'react';  const ReactSharedInternals =   React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;  export default ReactSharedInternals;<\/code><\/pre>\n<p>\u0414\u0430 <code>ReactSharedInternals<\/code> \u044d\u0442\u043e \u0442\u0430 \u0441\u0430\u043c\u0430\u044f \u0441\u043c\u0435\u0448\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f &#171;SECRET INTERNALS DO NOT USE OR YOU WILL BE FIRED&#187;. \u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/React.js#L107\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/a>,  \u0442\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0432 \u0441\u0435\u0431\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442, \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>ReactCurrentDispatcher<\/code><\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>ReactCurrentDispatcher<\/code> \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0444\u0430\u0439\u043b\u0430 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L386\" rel=\"noopener noreferrer nofollow\">packages\/react-reconcilier\/src\/ReactFiberHooks.new.js<\/a>. <\/p>\n<pre><code class=\"javascript\">if (__DEV__) {   if (current !== null &amp;&amp; current.memoizedState !== null) {     ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV;   } else if (hookTypesDev !== null) {     \/\/ This dispatcher handles an edge case where a component is updating,     \/\/ but no stateful hooks have been used.     \/\/ We want to match the production code behavior (which will use HooksDispatcherOnMount),     \/\/ but with the extra DEV validation to ensure hooks ordering hasn't changed.     \/\/ This dispatcher does that.     ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV;   } else {     ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV;   } } else {   ReactCurrentDispatcher.current =     current === null || current.memoizedState === null       ? HooksDispatcherOnMount       : HooksDispatcherOnUpdate; }<\/code><\/pre>\n<p>\u0412 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>ReactCurrentDispatcher.current<\/code> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0443 <code>InDEV<\/code>, \u0434\u0430 \u0438 \u043e\u043d\u0438 \u0432\u0441\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c <code>if<\/code> \u0431\u043b\u043e\u043a\u0435 \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043d\u0430 <code>__DEV__<\/code> \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <code>else<\/code> \u0441\u0435\u043a\u0446\u0438\u044e. \u0422\u0430\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>ReactCurrentDispatcher.current<\/code> \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442 <code>HooksDispatcherOnMount<\/code> \u0438\u043b\u0438 <code>HooksDispatcherOnUpdate<\/code>. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0435 <code>HooksDispatcherOnMount<\/code> \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0445\u0443\u043a\u043e\u0432, \u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u044d\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f (<a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1911\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442<\/a>):<\/p>\n<pre><code class=\"javascript\">const HooksDispatcherOnMount: Dispatcher = {   useCallback: mountCallback,   useContext: readContext,   useEffect: mountEffect,   ... };<\/code><\/pre>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0438\u0436\u0435 \u043c\u044b \u043d\u0430\u0439\u0434\u0435\u043c <code>HooksDispatcherOnUpdate<\/code>, \u0433\u0434\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0445\u0443\u043a\u043e\u0432, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043d\u043e\u0432\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f (<a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1936\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442<\/a>):<\/p>\n<pre><code class=\"javascript\">const HooksDispatcherOnUpdate: Dispatcher = {   useCallback: updateCallback,   useContext: readContext,   useEffect: updateEffect,   ... };<\/code><\/pre>\n<p>\u0418 \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0438\u0441\u043f\u0430\u0442\u0447\u0435\u0440\u044b, \u0438\u0445 \u043c\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u043e \u044f \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u043d\u0435\u0448\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u044d\u0442\u0438 2, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0438\u0441\u043f\u0430\u0442\u0447\u0435\u0440\u044b \u043b\u0438\u0431\u043e \u0434\u043b\u044f dev \u0440\u0435\u0436\u0438\u043c\u0430, \u043b\u0438\u0431\u043e \u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445 \u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0443\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435:<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0445\u0443\u043a\u043e\u043c <code>useEffect<\/code>. \u0418 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>HooksDispatcherOnMount.useEffect<\/code> \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>mountEffect<\/code>. \u0414\u0430\u043b\u0435\u0435, \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0436\u0435 <code>HooksDispatcherOnUpdate.useEffect<\/code> \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>updateEffect<\/code>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/75a\/bbe\/29f\/75abbe29fc19d0dbf0375845162173b1.jpg\" width=\"1073\" height=\"904\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 <em>React<\/em>. \u0412\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043e\u0434\u0438\u043d \u0445\u0443\u043a, \u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043e\u0442 \u043d\u0430\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u0430\u043c \u043f\u043e\u0434\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c useCallback<\/h2>\n<p>\u041c\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u043b\u0433\u043e \u0438\u0441\u043a\u0430\u043b\u0438 \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0445\u0443\u043a\u043e\u0432, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1443\" rel=\"noopener noreferrer nofollow\">mountCallback<\/a>. <\/p>\n<pre><code class=\"javascript\">function mountCallback&lt;T&gt;(callback: T, deps: Array&lt;mixed&gt; | void | null): T {   const hook = mountWorkInProgressHook();   const nextDeps = deps === undefined ? null : deps;   hook.memoizedState = [callback, nextDeps];   return callback; }<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>callback<\/code> \u0438 <code>deps<\/code>. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>mountWorkInProgressHook()<\/code> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e <code>hook<\/code>, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0437\u0436\u0435. \u0410 \u043f\u043e\u043a\u0430 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u043f\u0440\u0438\u0441\u043b\u0430\u043b\u0438 <code>deps<\/code>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 <code>null<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>undefined<\/code>. \u0418 \u0434\u0430\u043b\u0435\u0435 \u0432 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 <code>hook<\/code> \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>memoizedState<\/code> \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0441\u043b\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <code>callback<\/code> \u0438 <code>deps<\/code>. \u0418 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>callback<\/code>.<\/p>\n<p>\u0414\u0430\u0436\u0435 \u043e\u0431\u0449\u0438\u0439 \u043e\u0441\u043c\u043e\u0442\u0440 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c. <code>mountCallback<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0410 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0443\u0434\u0430-\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432\u043e\u0442 \u043c\u044b \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0445\u0443\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u043d\u0434\u0435\u0440\u043e\u0432, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u0435\u0440\u043d\u0443\u043b\u0438 <code>callback<\/code>, \u0442.\u043a. \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043d\u0435\u0447\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u0441\u0430\u043c\u0443 \u043f\u0440\u0438\u0441\u043b\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1450\" rel=\"noopener noreferrer nofollow\">updateCallback<\/a>:<\/p>\n<pre><code class=\"javascript\">function updateCallback&lt;T&gt;(callback: T, deps: Array&lt;mixed&gt; | void | null): T {   const hook = updateWorkInProgressHook();   const nextDeps = deps === undefined ? null : deps;   const prevState = hook.memoizedState;   if (prevState !== null) {     if (nextDeps !== null) {       const prevDeps: Array&lt;mixed&gt; | null = prevState[1];       if (areHookInputsEqual(nextDeps, prevDeps)) {         return prevState[0];       }     }   }   hook.memoizedState = [callback, nextDeps];   return callback; }<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>callback<\/code> \u0438 <code>deps<\/code>. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0443\u0436\u0435 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>updateWorkInProgressHook()<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>hook<\/code>, \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u0432\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0445\u0443\u043a\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>mountCallback<\/code>. \u0414\u0430\u043b\u0435\u0435 \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>undefined<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 <code>null<\/code>.<\/p>\n<p>\u0418 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f. \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>mountCallback<\/code> \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b\u0438 <code>callback<\/code> \u0438 <code>deps<\/code> \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>memoizedState<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>hook<\/code>:<\/p>\n<pre><code class=\"javascript\">function mountCallback&lt;T&gt;(...): T {   ...   hook.memoizedState = [callback, nextDeps];   ... }<\/code><\/pre>\n<p>\u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u043b\u0438 \u043c\u044b \u0432 \u043d\u0435\u0433\u043e \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0440\u0430\u043d\u0435\u0435 <code>prevState !== null<\/code>. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 <code>nextDeps !== null<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043f\u0440\u0438\u0441\u043b\u0430\u043b\u0438 \u043b\u0438 \u043d\u0430\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 . \u0418 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b, \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 const <code>prevDeps = prevState[1]<\/code> \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 <code>areHookInputsEqual(nextDeps, prevDeps)<\/code>. \u0418 \u0435\u0441\u043b\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 <code>return prevState[0]<\/code>.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0436\u0435 \u0445\u043e\u0442\u044c \u043e\u0434\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u043e\u0441\u044c, \u0442\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 <code>hook.memoizedState = [callback, nextDeps]<\/code> . \u0418 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0435\u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <code>callback<\/code>, \u0430 \u043f\u0440\u0438\u0441\u043b\u0430\u043d\u043d\u044b\u0439 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. <\/p>\n<p>\u0414\u0443\u043c\u0430\u044e \u043e\u0431\u0449\u0443\u044e \u0438\u0434\u0435\u044e \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0445\u0443\u043a <code>useCallback<\/code> \u0432\u044b \u0443\u043b\u043e\u0432\u0438\u043b\u0438. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0435\u0435 \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435 \u0432 \u0432\u044b\u043f\u0443\u0441\u043a\u0435 \u201c<a href=\"https:\/\/youtu.be\/2Wp7QPTkpms\" rel=\"noopener noreferrer nofollow\">\u0427\u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043e useCallback?<\/a>\u201d. \u0413\u0434\u0435 \u043c\u044b \u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u0432\u043e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <code>useCallback<\/code>. \u041d\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0434\u0435\u0442\u0430\u043b\u0438. \u0410 \u0432 \u044d\u0442\u043e\u043c \u0445\u0443\u043a\u0435 \u043c\u044b \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u043b\u0438, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0435 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>hook<\/code>, \u0438 \u043a\u0430\u043a \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>areHookInputsEqual<\/code> \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L286\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u043c \u0436\u0435 \u0444\u0430\u0439\u043b\u0435<\/a>:<\/p>\n<pre><code class=\"javascript\">function areHookInputsEqual(   nextDeps: Array&lt;mixed&gt;,   prevDeps: Array&lt;mixed&gt; | null, ) {   ...    if (prevDeps === null) {     return false;   }    ...      for (let i = 0; i &lt; prevDeps.length &amp;&amp; i &lt; nextDeps.length; i++) {     if (is(nextDeps[i], prevDeps[i])) {       continue;     }     return false;   }   return true; }<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 2 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0418 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 (<code>...<\/code>) \u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u0431\u043b\u043e\u043a\u0438 \u0434\u043b\u044f \u0434\u0435\u0432 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f (<code>__DEV__<\/code>). \u0418 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435. \u041c\u044b \u0432\u0438\u0434\u0438\u043c <code>for<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 \u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0430\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u044b:<\/p>\n<pre><code class=\"javascript\">[user, book, author] === [user, book]<\/code><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0434\u043b\u0438\u043d\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0434 \u043e\u0431\u044a\u0435\u043a\u0442:<\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u043b\u043e\u0445\u043e const deps = [props.user, props.book]  if (hasAuthor) {   deps.push(props.author); }  \/\/ [user, book, author] === [user, book]  \/\/ \u0445\u043e\u0440\u043e\u0448\u043e  const deps = [props.user, props.book, hasAuthor ? props.author : null];  \/\/ [user, book, author] !== [user, book, null]<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>is(nextDeps[i], prevDeps[i])<\/code> \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0440\u0430\u0432\u043d\u044b \u0442\u043e \u0438\u0434\u0435\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u0417\u0434\u0435\u0441\u044c \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e, \u0442\u043e \u0447\u0442\u043e \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c i-\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 i-\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0442\u043e\u0440\u043e\u0433\u043e, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u0438\u043d\u0430\u0447\u0435 \u0432\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442\u0435 \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u044e: <\/p>\n<pre><code class=\"javascript\">[user, book, author] !== [user, author, book]<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>is<\/code>. \u041e\u043d\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/shared\/objectIs.js#L20\" rel=\"noopener noreferrer nofollow\">packages\/shared\/objectIs.js<\/a>:<\/p>\n<pre><code class=\"javascript\">function is(x: any, y: any) {   return (     (x === y &amp;&amp; (x !== 0 || 1 \/ x === 1 \/ y)) || (x !== x &amp;&amp; y !== y)   ); }  const objectIs: (x: any, y: any) =&gt; boolean =   typeof Object.is === 'function' ? Object.is : is;  export default objectIs;<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u043e\u0435 API <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Object\/is\" rel=\"noopener noreferrer nofollow\">Object.is (MDN)<\/a> \u0438 \u0435\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u043f\u043e \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435, \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0438\u0444\u0438\u043b.<\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u0435\u0449\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437 \u0443\u0432\u0438\u0434\u0435\u043d\u043d\u043e\u0433\u043e, \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e props \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f.<\/p>\n<pre><code class=\"javascript\">useEffect(() =&gt; {   ... }, [props.user]);<\/code><\/pre>\n<p>\u041d\u043e \u0441\u0443\u0434\u044f \u043f\u043e \u043a\u043e\u0434\u0443, \u043d\u0430\u043c \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>props.book.author.id<\/code>, \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043c\u043f\u0435\u0440\u0441\u0430\u043d\u0434\u044b \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440:<\/p>\n<pre><code>useEffect(() =&gt; {   ... }, [   props.book.author.id,   props.selectedBooks &amp;&amp; props.selectedBooks.id,   props.book.isFavorite ? props.book : null, ]);<\/code><\/pre>\n<p>\u041d\u043e \u0435\u0449\u0435 \u0438\u0437 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 <code>props<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>ref<\/code> \u0438\u043b\u0438 \u0436\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c <code>window.location.pathname<\/code>:<\/p>\n<pre><code>useEffect(() =&gt; {   ... }, [   scrollRef.current,   window.location.pathname, ]);<\/code><\/pre>\n<p> \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438\u0448\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Object.is<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0430\u0436\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0440\u0435\u0448\u0438\u0442\u044c \u0441\u0442\u043e\u0438\u0442 \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c mountWorkInProgressHook()<\/h2>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b <code>mountWorkInProgressHook()<\/code>, <code>updateWorkInProgressHook()<\/code>. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L522\" rel=\"noopener noreferrer nofollow\">\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430<\/a>:<\/p>\n<pre><code class=\"javascript\">function mountWorkInProgressHook(): Hook {   const hook: Hook = {     memoizedState: null,      baseState: null,     baseQueue: null,     queue: null,      next: null,   };    if (workInProgressHook === null) {     \/\/ This is the first hook in the list     currentlyRenderingFiber.memoizedState = workInProgressHook = hook;   } else {     \/\/ Append to the end of the list     workInProgressHook = workInProgressHook.next = hook;   }   return workInProgressHook; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>hook<\/code>, \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>memoizedState<\/code> \u043d\u0430\u043c \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0442\u0430\u043c \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438. \u0421 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u043d\u0430\u043c \u0435\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043c\u0435\u043b\u044c\u043a\u0430\u0435\u0442 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>workInProgressHook<\/code>. \u041e\u043d\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0432\u0435\u0440\u0445\u0443 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0432\u043d\u0430 <code>null<\/code>.<\/p>\n<pre><code class=\"javascript\">\/\/ Hooks are stored as a linked list on the fiber's memoizedState field. The \/\/ current hook list is the list that belongs to the current fiber. The \/\/ work-in-progress hook list is a new list that will be added to the \/\/ work-in-progress fiber. let currentHook: Hook | null = null; let workInProgressHook: Hook | null = null;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 (\u0441\u043c. \u043a\u043e\u0434 \u043d\u0438\u0436\u0435) \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0435\u0441\u043b\u0438 <code>workInProgressHook<\/code> \u0432\u0441\u0435 \u0435\u0449\u0435 \u0440\u0430\u0432\u0435\u043d <code>null<\/code>, \u0442\u043e\u0433\u0434\u0430 \u0441\u043f\u0435\u0440\u0432\u0430 \u043c\u044b \u0432\u043d\u043e\u0432\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>hook<\/code> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0432 <code>workInProgressHook<\/code>. \u0418 \u0442\u043e\u0442 \u0436\u0435 <code>hook<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>currentlyRenderingFiber.memoizedState<\/code>. \u0418 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>workInProgressHook<\/code>:<\/p>\n<pre><code class=\"javascript\">function mountWorkInProgressHook(): Hook {   ...    if (workInProgressHook === null) {     workInProgressHook = hook;     currentlyRenderingFiber.memoizedState = hook;   } else {     ...   }    return workInProgressHook; }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u0443\u043a\u0430, \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>workInProgressHook<\/code> \u0443\u0436\u0435 \u0440\u0430\u0432\u0435\u043d \u043d\u0435 <code>null<\/code>, \u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0445\u0443\u043a. \u0418 \u0432\u043d\u043e\u0432\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>hook<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0432 \u043f\u043e\u043b\u0435 <code>workInProgressHook.next<\/code>. \u0418 \u0434\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>workInProgressHook<\/code>.<\/p>\n<pre><code class=\"javascript\">function mountWorkInProgressHook(): Hook {   ...    if (workInProgressHook === null) {     ...   } else {     workInProgressHook.next = hook;     workInProgressHook = hook;   }      return workInProgressHook; }<\/code><\/pre>\n<p>\u0418\u0437 \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0443\u0436\u0435 \u0432\u044b\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 8 \u0445\u0443\u043a\u043e\u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/003\/95d\/ea0\/00395dea091d62ac3d73635aa09570c7.jpg\" width=\"1289\" height=\"931\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0437 8 \u0445\u0443\u043a\u043e\u0432 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430, \u0433\u0434\u0435 <code>currentlyRenderingFiber.memoizedState<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0445\u0443\u043a, \u0430 <code>workInProgressHook<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0445\u0443\u043a. \u041d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a <strong>Linked List<\/strong>.<\/p>\n<p>\u0422\u043e \u0447\u0442\u043e \u043c\u044b \u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435 &#8212; \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440, \u043a\u0430\u043a \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u0443\u043a\u043e\u0432 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0442\u044c \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0436\u0438\u0437\u043d\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043d\u043e \u0441\u0430\u043c \u043c\u0435\u0442\u043e\u0434 <code>updateWorkInProgressHook<\/code> \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043e\u043d \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <strong>Linked List <\/strong>\u0442\u043e \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u0442\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e, \u043d\u043e \u0441\u0443\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u0436\u0435. \u041e\u0441\u0442\u0430\u0432\u043b\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u042d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u043e\u0434 \u043e\u0442 \u0445\u0443\u043a\u043e\u0432. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0430\u0440\u0430\u043c\u0438 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u043c \u0445\u0443\u043a\u0430 (\u0438\u043b\u0438 \u0435\u0433\u043e \u043a\u043b\u043e\u043d\u043e\u043c), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>mountWorkInProgressHook()<\/code> \u0438 \u043f\u043e\u0442\u043e\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437 <code>updateWorkInProgressHook()<\/code>. \u0418 \u043a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u0430\u043c \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438, \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u0430\u0436\u0435 \u043a\u043e\u0434 \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439. <\/p>\n<p>\u041a\u0430\u043a \u044f \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f &#8212; \u0431\u0430\u0437\u0430. \u041d\u0430 \u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u043d\u044c\u0448\u0435 \u0440\u0430\u0437\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0435\u043c\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \ud83d\ude09<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0412\u0430\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0442\u043e \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c, \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c <a href=\"https:\/\/www.patreon.com\/ITSin9k\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<p>\u0427\u0430\u043e!<\/p>\n<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/537410\/\"> https:\/\/habr.com\/ru\/post\/537410\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u043e\u043d\u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u043b\u043e\u043d\u0433 \u0440\u0438\u0434\u0430\u043c\u0438, \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0445\u0443\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0438 \u043f\u043e\u0442\u043e\u043c \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u0443 (<a href=\"https:\/\/youtu.be\/kcHEWut-DUA\" rel=\"noopener noreferrer nofollow\">\u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u043e\u0439 \u0432\u0438\u0434\u0435\u043e<\/a>).<\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u0445\u0443\u043a\u043e\u0432<\/h2>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <a href=\"https:\/\/github.com\/facebook\/react\" rel=\"noopener noreferrer nofollow\">React-\u0430 \u0432 Github<\/a>. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043c\u043e\u043d\u043e\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0433\u0434\u0435 \u0432\u0441\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043d\u0430\u043c \u043f\u0430\u043a\u0435\u0442\u044b \u043b\u0435\u0436\u0430\u0442 \u0432 <em>packages<\/em>. \u041d\u0438\u0436\u0435 \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0435 \u044f \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043d\u0435\u0439 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0431\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <em>react-dom<\/em>. \u0418\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <em>render<\/em>, \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 <em>React<\/em> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 <em>HTML<\/em>.<\/p>\n<pre><code class=\"javascript\">import React from \"react\"; import ReactDOM from \"react-dom\";  import App from \".\/App\";  ReactDOM.render(&lt;App \/&gt;, document.getElementById(\"root\"));<\/code><\/pre>\n<p>\u0425\u0443\u043a\u0438 \u0436\u0435 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <em>React<\/em>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 <em>package<\/em> \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u0417\u0430\u0439\u0434\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u0438 \u043e\u0442\u043a\u0440\u043e\u0435\u043c <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/index.js#L48\" rel=\"noopener noreferrer nofollow\">index.js<\/a> \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"javascript\">export {   ...   useCallback,   useContext,   useEffect,   ...   __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,   ... } from '.\/src\/React';<\/code><\/pre>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0445\u0443\u043a\u0438 <code>useCallback<\/code>, <code>useContext<\/code>, <code>useEffect<\/code>. \u0418\u0437 \u0441\u043c\u0435\u0448\u043d\u043e\u0433\u043e, \u043c\u043d\u0435 \u0435\u0449\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f &#171;SECRET INTERNALS DO NOT USE OR YOU WILL BE FIRED&#187;. \u0412\u0438\u0434\u0438\u043c\u043e \u0443 \u043d\u0438\u0445 \u0442\u0430\u043a \u0436\u0435 \u0435\u0441\u0442\u044c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u043e\u043b\u0433, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0449\u0435 \u0438 \u0443\u0432\u043e\u043b\u0438\u0442\u044c \u043c\u043e\u0433\u0443\u0442))) \u042d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0436\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/React.js#L87\" rel=\"noopener noreferrer nofollow\">packages\/react\/src\/React.js<\/a>. \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0442\u043e\u0436\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u043e\u043c \u0445\u0443\u043a\u043e\u0432 \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/ReactHooks.js#L123\" rel=\"noopener noreferrer nofollow\">packages\/react\/src\/ReactHooks.js<\/a>. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0436\u0435 \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u0435 \u043a\u0430\u043a\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0445\u0443\u043a\u043e\u0432:<\/p>\n<pre><code class=\"javascript\">export function useCallback&lt;T&gt;(   callback: T,   deps: Array&lt;mixed&gt; | void | null, ): T {   const dispatcher = resolveDispatcher();   return dispatcher.useCallback(callback, deps); }<\/code><\/pre>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0434\u0435\u0441\u044c <code>useCallback<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>callback<\/code> \u0438 <code>deps<\/code>, \u043d\u043e \u044d\u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u043b\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0432 \u0432\u0438\u0434\u0435 <code>dispatcher<\/code> \u0438 \u0443\u0436\u0435 \u0438\u0437 \u043d\u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u043f\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>useCallback<\/code>.&nbsp; \u0421\u0430\u043c \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/ReactHooks.js#L25\" rel=\"noopener noreferrer nofollow\">resolveDispatcher<\/a> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0432\u0435\u0440\u0445\u0443 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">import ReactCurrentDispatcher from '.\/ReactCurrentDispatcher';  function resolveDispatcher() {   const dispatcher = ReactCurrentDispatcher.current;   invariant(     dispatcher !== null,     'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +       ' one of the following reasons:\\n' +       '1. You might have mismatching versions of React and the renderer (such as React DOM)\\n' +       '2. You might be breaking the Rules of Hooks\\n' +       '3. You might have more than one copy of React in the same app\\n' +       'See https:\/\/reactjs.org\/link\/invalid-hook-call for tips about how to debug and fix this problem.',   );   return dispatcher; }<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e <code>dispatcher<\/code> \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>ReactCurrentDispatcher<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0442\u0441\u044f \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c. \u0410 \u0435\u0441\u043b\u0438 \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b \u043c\u0435\u0442\u043e\u0434 <code>invariant<\/code>, <a href=\"https:\/\/ru.reactjs.org\/docs\/codebase-overview.html#warnings-and-invariants\" rel=\"noopener noreferrer nofollow\">\u0432\u043e\u0442 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442.<\/a> \u0410 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438 \u0444\u0430\u0439\u043b <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/ReactCurrentDispatcher.js#L15\" rel=\"noopener noreferrer nofollow\">packages\/react\/src\/ReactCurrentDispatcher.js<\/a>.<\/p>\n<pre><code class=\"javascript\">import type {Dispatcher} from 'react-reconciler\/src\/ReactInternalTypes';  \/**  * Keeps track of the current dispatcher.  *\/ const ReactCurrentDispatcher = {   \/**    * @internal    * @type {ReactComponent}    *\/   current: (null: null | Dispatcher), };<\/code><\/pre>\n<p>\u0418 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0441 \u0436\u0434\u0435\u0442 \u043b\u0435\u0433\u043a\u043e\u0435 \u0440\u0430\u0437\u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u044d\u0442\u043e\u0442 <code>current<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u044f\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0442\u043e \u0441\u0435\u0442\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043d\u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e. \u041d\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430. \u0422\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0442\u044f\u0442\u0441\u044f \u0432 <code>current<\/code> \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Dispatcher<\/code>. \u0418 \u043e\u043d \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0442\u0441\u044f \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 <em>react-reconcilier<\/em>.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0435\u0440\u0435\u0448\u0435\u043b \u0432 \u043f\u0430\u043a\u0435\u0442 <em>react-reconcilier<\/em> \u0438 \u043f\u043e\u0438\u0441\u043a\u0430\u043b \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043d\u0430\u043c \u0444\u0430\u0439\u043b. \u0418 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L100\" rel=\"noopener noreferrer nofollow\">packages\/react-reconcilier\/src\/ReactFiberHooks.new.js<\/a>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0441\u044f \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>ReactCurrentDispatcher<\/code><\/p>\n<pre><code class=\"javascript\">import ReactSharedInternals from 'shared\/ReactSharedInternals';  const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals;<\/code><\/pre>\n<p>\u042f \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u043b \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>ReactSharedInternals<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>ReactCurrentDispatcher<\/code>. \u0418 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0432 \u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/shared\/ReactSharedInternals.js#L12\" rel=\"noopener noreferrer nofollow\">packages\/shared\/ReactSharedInternals.js<\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 :<\/p>\n<pre><code class=\"javascript\">import * as React from 'react';  const ReactSharedInternals =   React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;  export default ReactSharedInternals;<\/code><\/pre>\n<p>\u0414\u0430 <code>ReactSharedInternals<\/code> \u044d\u0442\u043e \u0442\u0430 \u0441\u0430\u043c\u0430\u044f \u0441\u043c\u0435\u0448\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f &#171;SECRET INTERNALS DO NOT USE OR YOU WILL BE FIRED&#187;. \u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/React.js#L107\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/a>,  \u0442\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0432 \u0441\u0435\u0431\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442, \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>ReactCurrentDispatcher<\/code><\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>ReactCurrentDispatcher<\/code> \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0444\u0430\u0439\u043b\u0430 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L386\" rel=\"noopener noreferrer nofollow\">packages\/react-reconcilier\/src\/ReactFiberHooks.new.js<\/a>. <\/p>\n<pre><code class=\"javascript\">if (__DEV__) {   if (current !== null &amp;&amp; current.memoizedState !== null) {     ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV;   } else if (hookTypesDev !== null) {     \/\/ This dispatcher handles an edge case where a component is updating,     \/\/ but no stateful hooks have been used.     \/\/ We want to match the production code behavior (which will use HooksDispatcherOnMount),     \/\/ but with the extra DEV validation to ensure hooks ordering hasn't changed.     \/\/ This dispatcher does that.     ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV;   } else {     ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV;   } } else {   ReactCurrentDispatcher.current =     current === null || current.memoizedState === null       ? HooksDispatcherOnMount       : HooksDispatcherOnUpdate; }<\/code><\/pre>\n<p>\u0412 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>ReactCurrentDispatcher.current<\/code> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0443 <code>InDEV<\/code>, \u0434\u0430 \u0438 \u043e\u043d\u0438 \u0432\u0441\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c <code>if<\/code> \u0431\u043b\u043e\u043a\u0435 \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043d\u0430 <code>__DEV__<\/code> \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <code>else<\/code> \u0441\u0435\u043a\u0446\u0438\u044e. \u0422\u0430\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>ReactCurrentDispatcher.current<\/code> \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442 <code>HooksDispatcherOnMount<\/code> \u0438\u043b\u0438 <code>HooksDispatcherOnUpdate<\/code>. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0435 <code>HooksDispatcherOnMount<\/code> \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0445\u0443\u043a\u043e\u0432, \u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u044d\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f (<a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1911\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442<\/a>):<\/p>\n<pre><code class=\"javascript\">const HooksDispatcherOnMount: Dispatcher = {   useCallback: mountCallback,   useContext: readContext,   useEffect: mountEffect,   ... };<\/code><\/pre>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0438\u0436\u0435 \u043c\u044b \u043d\u0430\u0439\u0434\u0435\u043c <code>HooksDispatcherOnUpdate<\/code>, \u0433\u0434\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0445\u0443\u043a\u043e\u0432, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043d\u043e\u0432\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f (<a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1936\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442<\/a>):<\/p>\n<pre><code class=\"javascript\">const HooksDispatcherOnUpdate: Dispatcher = {   useCallback: updateCallback,   useContext: readContext,   useEffect: updateEffect,   ... };<\/code><\/pre>\n<p>\u0418 \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0438\u0441\u043f\u0430\u0442\u0447\u0435\u0440\u044b, \u0438\u0445 \u043c\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u043e \u044f \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u043d\u0435\u0448\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u044d\u0442\u0438 2, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0438\u0441\u043f\u0430\u0442\u0447\u0435\u0440\u044b \u043b\u0438\u0431\u043e \u0434\u043b\u044f dev \u0440\u0435\u0436\u0438\u043c\u0430, \u043b\u0438\u0431\u043e \u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445 \u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0443\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435:<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0445\u0443\u043a\u043e\u043c <code>useEffect<\/code>. \u0418 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>HooksDispatcherOnMount.useEffect<\/code> \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>mountEffect<\/code>. \u0414\u0430\u043b\u0435\u0435, \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0436\u0435 <code>HooksDispatcherOnUpdate.useEffect<\/code> \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>updateEffect<\/code>.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 <em>React<\/em>. \u0412\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043e\u0434\u0438\u043d \u0445\u0443\u043a, \u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043e\u0442 \u043d\u0430\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u0430\u043c \u043f\u043e\u0434\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c useCallback<\/h2>\n<p>\u041c\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u043b\u0433\u043e \u0438\u0441\u043a\u0430\u043b\u0438 \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0445\u0443\u043a\u043e\u0432, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1443\" rel=\"noopener noreferrer nofollow\">mountCallback<\/a>. <\/p>\n<pre><code class=\"javascript\">function mountCallback&lt;T&gt;(callback: T, deps: Array&lt;mixed&gt; | void | null): T {   const hook = mountWorkInProgressHook();   const nextDeps = deps === undefined ? null : deps;   hook.memoizedState = [callback, nextDeps];   return callback; }<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>callback<\/code> \u0438 <code>deps<\/code>. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>mountWorkInProgressHook()<\/code> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e <code>hook<\/code>, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0437\u0436\u0435. \u0410 \u043f\u043e\u043a\u0430 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u043f\u0440\u0438\u0441\u043b\u0430\u043b\u0438 <code>deps<\/code>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 <code>null<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>undefined<\/code>. \u0418 \u0434\u0430\u043b\u0435\u0435 \u0432 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 <code>hook<\/code> \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>memoizedState<\/code> \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0441\u043b\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <code>callback<\/code> \u0438 <code>deps<\/code>. \u0418 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>callback<\/code>.<\/p>\n<p>\u0414\u0430\u0436\u0435 \u043e\u0431\u0449\u0438\u0439 \u043e\u0441\u043c\u043e\u0442\u0440 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c. <code>mountCallback<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0410 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0443\u0434\u0430-\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432\u043e\u0442 \u043c\u044b \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0445\u0443\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u043d\u0434\u0435\u0440\u043e\u0432, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u0435\u0440\u043d\u0443\u043b\u0438 <code>callback<\/code>, \u0442.\u043a. \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043d\u0435\u0447\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u0441\u0430\u043c\u0443 \u043f\u0440\u0438\u0441\u043b\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1450\" rel=\"noopener noreferrer nofollow\">updateCallback<\/a>:<\/p>\n<pre><code class=\"javascript\">function updateCallback&lt;T&gt;(callback: T, deps: Array&lt;mixed&gt; | void | null): T {   const hook = updateWorkInProgressHook();   const nextDeps = deps === undefined ? null : deps;   const prevState = hook.memoizedState;   if (prevState !== null) {     if (nextDeps !== null) {       const prevDeps: Array&lt;mixed&gt; | null = prevState[1];       if (areHookInputsEqual(nextDeps, prevDeps)) {         return prevState[0];       }     }   }   hook.memoizedState = [callback, nextDeps];   return callback; }<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>callback<\/code> \u0438 <code>deps<\/code>. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0443\u0436\u0435 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>updateWorkInProgressHook()<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>hook<\/code>, \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u0432\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0445\u0443\u043a\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>mountCallback<\/code>. \u0414\u0430\u043b\u0435\u0435 \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>undefined<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 <code>null<\/code>.<\/p>\n<p>\u0418 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f. \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>mountCallback<\/code> \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b\u0438 <code>callback<\/code> \u0438 <code>deps<\/code> \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>memoizedState<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>hook<\/code>:<\/p>\n<pre><code class=\"javascript\">function mountCallback&lt;T&gt;(...): T {   ...   hook.memoizedState = [callback, nextDeps];   ... }<\/code><\/pre>\n<p>\u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u043b\u0438 \u043c\u044b \u0432 \u043d\u0435\u0433\u043e \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0440\u0430\u043d\u0435\u0435 <code>prevState !== null<\/code>. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 <code>nextDep<\/code><\/p>\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-316590","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316590","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=316590"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316590\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}