{"id":444178,"date":"2025-01-08T03:00:58","date_gmt":"2025-01-08T03:00:58","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=444178"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2025-01-08T03:00:58","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=444178","title":{"rendered":"<span>\u0412\u0437\u0433\u043b\u044f\u0434 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043d\u0430 useMemo, useCallback \u0438 React.memo \u0432 React: \u043a\u043e\u0433\u0434\u0430 \u0438\u0445 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 React \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u2014 \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043b\u0438\u0448\u044c \u043a\u0440\u0430\u0435\u043c \u0443\u0445\u0430 \u0441\u043b\u044b\u0448\u0430\u0442 \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0445\u0443\u043a\u043e\u0432 useMemo, useCallback \u0438 React.memo \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430. \u041d\u043e \u0435\u0441\u043b\u0438 \u0431\u0435\u0437\u0434\u0443\u043c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u043d\u0430\u0432\u0440\u0435\u0434\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c useMemo, useCallback \u0438 React.memo, \u0430 \u043a\u043e\u0433\u0434\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043b\u0438\u0448\u043d\u0435. \u041c\u044b \u0438\u0437\u0443\u0447\u0438\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0445\u0443\u043a\u043e\u0432, \u0438\u0445 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432 React, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0445\u0443\u043a\u043e\u0432.<\/p>\n<h3>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0432 React<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0442\u0430\u043b\u0438, \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0432 React.<\/p>\n<ul>\n<li>\n<p><strong>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/strong> \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/strong> \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0431\u0443\u0434\u0443\u0442 &#171;\u043d\u043e\u0432\u044b\u043c\u0438&#187; \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 (\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0438 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e). \u041e\u0434\u043d\u0430\u043a\u043e \u0445\u0443\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a useState \u0438 useEffect, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c React.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0445\u0443\u043a\u043e\u0432<\/h3>\n<h4>React.memo<\/h4>\n<p>React.memo \u2014 \u044d\u0442\u043e <strong>\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 (Higher Order Component, HOC)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0441\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c, React \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440, \u043e\u043d \u0432\u0435\u0440\u043d\u0451\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430.<\/p>\n<p><strong>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u041f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (shallow equal):<\/strong> React.memo \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u0440\u043e\u043f\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Object.is, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0438\u0445 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0441 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430\u043c\u0438:<\/strong> \u041b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043f\u0441\u044b \u2014 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b (\u0447\u0438\u0441\u043b\u0430, \u0441\u0442\u0440\u043e\u043a\u0438, \u0431\u0443\u043b\u0435\u0432\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f).<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0441 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438:<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0441\u044b \u2014 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c useMemo \u0438\u043b\u0438 useCallback \u0434\u043b\u044f \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u043f\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f React.memo:<\/h4>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 1: \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430\u043c\u0438 \u0431\u0435\u0437 React.memo<\/h3>\n<pre><code>function Display({ value }) {   console.log('\u0420\u0435\u043d\u0434\u0435\u0440 Display');   return &lt;div&gt;{value}&lt;\/div&gt;; }  function App() {   const [count, setCount] = React.useState(0);    return (     &lt;div&gt;       &lt;Display value=\"\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\" \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong> \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Display \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440, \u0445\u043e\u0442\u044f \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u0441 value \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0435\u0439\u0442, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 App (\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0441\u0442\u0435\u0439\u0442) \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 2: \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438, \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u044b\u0439 \u0432 React.memo<\/h3>\n<pre><code>const Display = React.memo(function Display({ value }) {   console.log('\u0420\u0435\u043d\u0434\u0435\u0440 Display');   return &lt;div&gt;{value}&lt;\/div&gt;; });  function App() {   const [count, setCount] = React.useState(0);    return (     &lt;div&gt;       &lt;Display value=\"\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\" \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong> \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Display \u043d\u0435 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0435\u0439\u0442\u0430 \u0432 App, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u0441 value \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f React.memo \u043e\u043d \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 3: \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043d\u0435\u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438, \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u044b\u0439 \u0432 React.memo<\/h3>\n<pre><code>const Display = React.memo(function Display({ data }) {   console.log('\u0420\u0435\u043d\u0434\u0435\u0440 Display');   return &lt;div&gt;{data.value}&lt;\/div&gt;; });  function App() {   const [count, setCount] = React.useState(0);   const data = { value: '\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442' };    return (     &lt;div&gt;       &lt;Display data={data} \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong> \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e data \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, Display \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435 App, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 data \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435, \u0438 \u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f (\u0441\u043d\u043e\u0432\u0430 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0438 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e). React.memo \u0432\u0438\u0434\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u043f\u0441 data \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f (\u0441\u0441\u044b\u043b\u043e\u0447\u043d\u043e), \u0438 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<p><strong>\u041a\u0430\u043a \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c:<\/strong><\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c useMemo \u0434\u043b\u044f \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 data:<\/p>\n<pre><code>const Display = React.memo(function Display({ data }) {   console.log('\u0420\u0435\u043d\u0434\u0435\u0440 Display');   return &lt;div&gt;{data.value}&lt;\/div&gt;; });  function App() {   const [count, setCount] = React.useState(0);   const data = React.useMemo(() =&gt; ({ value: '\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442' }), []);    return (     &lt;div&gt;       &lt;Display data={data} \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c data \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u0438 Display \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h4>useCallback<\/h4>\n<p>useCallback \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f useCallback:<\/h4>\n<pre><code>const Button = React.memo(function Button({ onClick, label }) {   console.log(`\u0420\u0435\u043d\u0434\u0435\u0440 \u043a\u043d\u043e\u043f\u043a\u0438: ${label}`);   return &lt;button onClick={onClick}&gt;{label}&lt;\/button&gt;; });  function Counter() {   const [count, setCount] = React.useState(0);    const increment = React.useCallback(() =&gt; setCount((c) =&gt; c + 1), []);    return (     &lt;div&gt;       &lt;h1&gt;\u0421\u0447\u0435\u0442\u0447\u0438\u043a: {count}&lt;\/h1&gt;       &lt;Button onClick={increment} label=\"\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c\" \/&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<h4>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/h4>\n<ul>\n<li>\n<p>increment \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0447\u0435\u0440\u0435\u0437 useCallback, \u0438 \u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u043f\u043e\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>Button \u043e\u0431\u0451\u0440\u043d\u0443\u0442 \u0432 React.memo, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u0441\u044b \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u043a. increment \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u043e\u043d\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435:<\/h4>\n<ul>\n<li>\n<p><strong>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c\u0438 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u043c\u0438 (stale closure).<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0441\u0451 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f:<\/strong> \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 increment \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439, \u0441\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435, \u043d\u043e useCallback \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u0442.\u043a. \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435\u043c<\/h3>\n<pre><code>function Counter() {   const [count, setCount] = React.useState(0);    const increment = React.useCallback(() =&gt; setCount(count + 1), []);    return (     &lt;div&gt;       &lt;h1&gt;\u0421\u0447\u0435\u0442\u0447\u0438\u043a: {count}&lt;\/h1&gt;       &lt;button onClick={increment}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p>count \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u0443 useCallback.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e, increment \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 count, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u043a\u043b\u0438\u043a\u043d\u0435\u043c 100500 \u0440\u0430\u0437.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c count \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0441\u044c \u0441\u043c\u044b\u0441\u043b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0442\u0430\u043a)<\/p>\n<\/li>\n<\/ul>\n<pre><code>const increment = React.useCallback(() =&gt; setCount(count + 1), [count]); <\/code><\/pre>\n<h4>useMemo<\/h4>\n<p>useMemo \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f useMemo<\/h4>\n<pre><code>function HeavyComputation({ num }) {   const compute = (n) =&gt; {     \/\/ \u0418\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439     let result = 0;     for (let i = 0; i &lt; 1e7; i++) {       result += n * Math.random();     }     return result;   };    const value = React.useMemo(() =&gt; compute(num), [num]);    return &lt;div&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439: {value}&lt;\/div&gt;; }  function App() {   const [number] = React.useState(42);   const [toggle, setToggle] = React.useState(false);    return (     &lt;div&gt;       &lt;button onClick={() =&gt; setToggle((t) =&gt; !t)}&gt;\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c&lt;\/button&gt;       &lt;HeavyComputation num={number} \/&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p>compute(num) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043f num \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u0442\u044f\u0436\u0435\u043b\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435 App.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432<\/h4>\n<pre><code>function App() {   const [count, setCount] = React.useState(0);    const data = React.useMemo(() =&gt; ({ value: '\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442' }), []);    return (     &lt;div&gt;       &lt;Display data={data} \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<ul>\n<li>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c data \u0438\u043c\u0435\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0435 \u043e\u0442 \u043d\u0435\u0433\u043e, \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0412\u043e\u043f\u0440\u043e\u0441 \u043a \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>function Button({ onClick, label }) {   console.log(`\u0420\u0435\u043d\u0434\u0435\u0440 \u043a\u043d\u043e\u043f\u043a\u0438: ${label}`);   return &lt;button onClick={onClick}&gt;{label}&lt;\/button&gt;; }  function Counter() {   const [count, setCount] = React.useState(0);    const increment = () =&gt; setCount(count + 1);    return (     &lt;div&gt;       &lt;h1&gt;\u0421\u0447\u0435\u0442\u0447\u0438\u043a: {count}&lt;\/h1&gt;       &lt;Button onClick={increment} label=\"\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c\" \/&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0435 Counter \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f increment (\u0434\u043b\u044f \u043d\u0430\u0441 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e), \u0438 Button \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u043f onClick.<\/p>\n<p><strong>\u0412\u043e\u043f\u0440\u043e\u0441:<\/strong> \u041a\u0430\u043a \u0434\u0443\u043c\u0430\u0435\u0442\u0435, \u0441\u0442\u0430\u043d\u0435\u0442 \u043b\u0438 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c increment \u0432 useCallback \u0438 Button \u0432 React.memo? \u041a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438?<\/p>\n<ol>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c useCallback \u0434\u043b\u044f increment \u0438 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c Button \u0432 React.memo.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043d\u0430\u0434 \u043e\u0442\u0432\u0435\u0442\u043e\u043c, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/strong><\/p>\n<h3>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/h3>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435<\/h4>\n<ul>\n<li>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u041a\u0410\u0416\u0414\u041e\u041c \u0440\u0435\u043d\u0434\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435, \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0412\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b<\/h3>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u043f\u0441\u0430 \u0438 \u043e\u0431\u0451\u0440\u043d\u0443\u0442 \u0432 React.memo, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0443 \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437 \u043f\u0440\u043e\u043f\u0441\u043e\u0432 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438, \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0440\u043e\u043f\u0441\u0430\u0445 \u043d\u0435 \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041e\u0442\u0432\u0435\u0442<\/h4>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 increment \u0432 useCallback \u0438 Button \u0432 React.memo \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438 Button. \u041d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0431\u043e \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043b\u0438\u0431\u043e \u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u043e\u0431\u0449\u0435.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443?<\/h3>\n<ul>\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/strong> \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Button \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0438 \u0432\u0440\u0435\u043c\u044f \u0435\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e. \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0435\u0433\u043e \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u043e\u0432 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0434\u0430\u0451\u0442 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b:<\/strong> \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 useCallback \u0438 React.memo \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0441\u0430\u043c\u0443 \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043f\u0441\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0443\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438:<\/strong> \u0412 useCallback \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c\u0438 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0420\u0435\u0437\u044e\u043c\u0438\u0440\u0443\u044f:<\/strong> \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 increment \u0432 useCallback \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 React.memo \u0434\u043b\u044f Button \u043d\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442 \u043d\u0430\u043c \u043a\u043e\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043b\u0443\u0447\u0448\u0435.<\/p>\n<h3>\u0421\u043c\u044b\u0441\u043b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<p><strong>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043c\u044b\u0441\u043b\u044c:<\/strong> \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0442\u0435\u043a\u0441\u0442 \u044f \u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0434\u043e\u043d\u0435\u0441\u0442\u0438 \u0434\u043e \u0432\u0430\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0443\u044e, \u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u0443\u0441\u043a\u043e\u043b\u044c\u0437\u0430\u044e\u0449\u0443\u044e \u043c\u044b\u0441\u043b\u044c \u2013 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430. \u041a\u0430\u0436\u0434\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u041a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043c\u0435\u043d\u0438\u0435 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c, \u0430 \u043d\u0443\u0436\u043d\u0430 \u043b\u0438 \u043d\u0430\u043c \u0437\u0434\u0435\u0441\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u044d\u0442\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u043b\u0438 \u043c\u044b \u0432 \u043b\u043e\u0432\u0443\u0448\u043a\u0443 \u043f\u0440\u0435\u0436\u0434\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u0430\u043c\u044f\u0442\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/strong> \u041d\u0435\u043b\u044c\u0437\u044f \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430, \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430:<\/strong> \u041f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e\u0435 \u043e\u0431\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 (\u0442\u0443\u0442 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0445\u043e\u043b\u0438\u0432\u0430\u0440\u0430, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f) \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 \u0445\u0443\u043a\u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u043a\u043e\u0434 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u043c\u0435\u043d\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u0443 \u043e\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438:<\/strong> \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u044d\u0442\u0438\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f:<\/strong> \u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0431\u0430\u0433\u0430\u043c. \u0412\u0441\u0435\u0433\u0434\u0430 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0431\u044b\u043b \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439. \u0412 19 \u0432\u0435\u0440\u0441\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 React \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u043d\u0430\u043c \u0441\u0432\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u0430\u0439\u043b\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c, \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u044d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u043d\u0430\u043c \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<p><strong>\u041f\u043e\u043c\u043d\u0438\u0442\u0435:<\/strong> \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u2014 \u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0438\u0441\u0442\u044b\u0439, \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434. \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438, \u0430 \u043d\u0435 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0435\u0439.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/871712\/\"> https:\/\/habr.com\/ru\/articles\/871712\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 React \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u2014 \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043b\u0438\u0448\u044c \u043a\u0440\u0430\u0435\u043c \u0443\u0445\u0430 \u0441\u043b\u044b\u0448\u0430\u0442 \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0445\u0443\u043a\u043e\u0432 useMemo, useCallback \u0438 React.memo \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430. \u041d\u043e \u0435\u0441\u043b\u0438 \u0431\u0435\u0437\u0434\u0443\u043c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u043d\u0430\u0432\u0440\u0435\u0434\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c useMemo, useCallback \u0438 React.memo, \u0430 \u043a\u043e\u0433\u0434\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043b\u0438\u0448\u043d\u0435. \u041c\u044b \u0438\u0437\u0443\u0447\u0438\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0445\u0443\u043a\u043e\u0432, \u0438\u0445 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432 React, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0445\u0443\u043a\u043e\u0432.<\/p>\n<h3>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0432 React<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0442\u0430\u043b\u0438, \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0432 React.<\/p>\n<ul>\n<li>\n<p><strong>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/strong> \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/strong> \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0431\u0443\u0434\u0443\u0442 &#171;\u043d\u043e\u0432\u044b\u043c\u0438&#187; \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 (\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0438 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e). \u041e\u0434\u043d\u0430\u043a\u043e \u0445\u0443\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a useState \u0438 useEffect, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c React.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0445\u0443\u043a\u043e\u0432<\/h3>\n<h4>React.memo<\/h4>\n<p>React.memo \u2014 \u044d\u0442\u043e <strong>\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 (Higher Order Component, HOC)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0441\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c, React \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440, \u043e\u043d \u0432\u0435\u0440\u043d\u0451\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430.<\/p>\n<p><strong>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u041f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (shallow equal):<\/strong> React.memo \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u0440\u043e\u043f\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Object.is, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0438\u0445 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0441 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430\u043c\u0438:<\/strong> \u041b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043f\u0441\u044b \u2014 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b (\u0447\u0438\u0441\u043b\u0430, \u0441\u0442\u0440\u043e\u043a\u0438, \u0431\u0443\u043b\u0435\u0432\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f).<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0441 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438:<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0441\u044b \u2014 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c useMemo \u0438\u043b\u0438 useCallback \u0434\u043b\u044f \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u043f\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f React.memo:<\/h4>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 1: \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430\u043c\u0438 \u0431\u0435\u0437 React.memo<\/h3>\n<pre><code>function Display({ value }) {   console.log('\u0420\u0435\u043d\u0434\u0435\u0440 Display');   return &lt;div&gt;{value}&lt;\/div&gt;; }  function App() {   const [count, setCount] = React.useState(0);    return (     &lt;div&gt;       &lt;Display value=\"\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\" \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong> \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Display \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440, \u0445\u043e\u0442\u044f \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u0441 value \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0435\u0439\u0442, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 App (\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0441\u0442\u0435\u0439\u0442) \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 2: \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438, \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u044b\u0439 \u0432 React.memo<\/h3>\n<pre><code>const Display = React.memo(function Display({ value }) {   console.log('\u0420\u0435\u043d\u0434\u0435\u0440 Display');   return &lt;div&gt;{value}&lt;\/div&gt;; });  function App() {   const [count, setCount] = React.useState(0);    return (     &lt;div&gt;       &lt;Display value=\"\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\" \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong> \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Display \u043d\u0435 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0435\u0439\u0442\u0430 \u0432 App, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u0441 value \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f React.memo \u043e\u043d \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 3: \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043d\u0435\u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u043f\u0441\u0430\u043c\u0438, \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u044b\u0439 \u0432 React.memo<\/h3>\n<pre><code>const Display = React.memo(function Display({ data }) {   console.log('\u0420\u0435\u043d\u0434\u0435\u0440 Display');   return &lt;div&gt;{data.value}&lt;\/div&gt;; });  function App() {   const [count, setCount] = React.useState(0);   const data = { value: '\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442' };    return (     &lt;div&gt;       &lt;Display data={data} \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong> \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e data \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, Display \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435 App, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 data \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435, \u0438 \u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f (\u0441\u043d\u043e\u0432\u0430 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0438 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e). React.memo \u0432\u0438\u0434\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u043f\u0441 data \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f (\u0441\u0441\u044b\u043b\u043e\u0447\u043d\u043e), \u0438 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<p><strong>\u041a\u0430\u043a \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c:<\/strong><\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c useMemo \u0434\u043b\u044f \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 data:<\/p>\n<pre><code>const Display = React.memo(function Display({ data }) {   console.log('\u0420\u0435\u043d\u0434\u0435\u0440 Display');   return &lt;div&gt;{data.value}&lt;\/div&gt;; });  function App() {   const [count, setCount] = React.useState(0);   const data = React.useMemo(() =&gt; ({ value: '\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442' }), []);    return (     &lt;div&gt;       &lt;Display data={data} \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c data \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u0438 Display \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h4>useCallback<\/h4>\n<p>useCallback \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f useCallback:<\/h4>\n<pre><code>const Button = React.memo(function Button({ onClick, label }) {   console.log(`\u0420\u0435\u043d\u0434\u0435\u0440 \u043a\u043d\u043e\u043f\u043a\u0438: ${label}`);   return &lt;button onClick={onClick}&gt;{label}&lt;\/button&gt;; });  function Counter() {   const [count, setCount] = React.useState(0);    const increment = React.useCallback(() =&gt; setCount((c) =&gt; c + 1), []);    return (     &lt;div&gt;       &lt;h1&gt;\u0421\u0447\u0435\u0442\u0447\u0438\u043a: {count}&lt;\/h1&gt;       &lt;Button onClick={increment} label=\"\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c\" \/&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<h4>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/h4>\n<ul>\n<li>\n<p>increment \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0447\u0435\u0440\u0435\u0437 useCallback, \u0438 \u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u043f\u043e\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>Button \u043e\u0431\u0451\u0440\u043d\u0443\u0442 \u0432 React.memo, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u0441\u044b \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u043a. increment \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u043e\u043d\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435:<\/h4>\n<ul>\n<li>\n<p><strong>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c\u0438 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u043c\u0438 (stale closure).<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0441\u0451 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f:<\/strong> \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 increment \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439, \u0441\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435, \u043d\u043e useCallback \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u0442.\u043a. \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435\u043c<\/h3>\n<pre><code>function Counter() {   const [count, setCount] = React.useState(0);    const increment = React.useCallback(() =&gt; setCount(count + 1), []);    return (     &lt;div&gt;       &lt;h1&gt;\u0421\u0447\u0435\u0442\u0447\u0438\u043a: {count}&lt;\/h1&gt;       &lt;button onClick={increment}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p>count \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u0443 useCallback.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e, increment \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 count, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u043a\u043b\u0438\u043a\u043d\u0435\u043c 100500 \u0440\u0430\u0437.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c count \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0441\u044c \u0441\u043c\u044b\u0441\u043b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0442\u0430\u043a)<\/p>\n<\/li>\n<\/ul>\n<pre><code>const increment = React.useCallback(() =&gt; setCount(count + 1), [count]); <\/code><\/pre>\n<h4>useMemo<\/h4>\n<p>useMemo \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f useMemo<\/h4>\n<pre><code>function HeavyComputation({ num }) {   const compute = (n) =&gt; {     \/\/ \u0418\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439     let result = 0;     for (let i = 0; i &lt; 1e7; i++) {       result += n * Math.random();     }     return result;   };    const value = React.useMemo(() =&gt; compute(num), [num]);    return &lt;div&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439: {value}&lt;\/div&gt;; }  function App() {   const [number] = React.useState(42);   const [toggle, setToggle] = React.useState(false);    return (     &lt;div&gt;       &lt;button onClick={() =&gt; setToggle((t) =&gt; !t)}&gt;\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c&lt;\/button&gt;       &lt;HeavyComputation num={number} \/&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p><strong>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p>compute(num) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043f num \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u0442\u044f\u0436\u0435\u043b\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435 App.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432<\/h4>\n<pre><code>function App() {   const [count, setCount] = React.useState(0);    const data = React.useMemo(() =&gt; ({ value: '\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442' }), []);    return (     &lt;div&gt;       &lt;Display data={data} \/&gt;       &lt;button onClick={() =&gt; setCount(count + 1)}&gt;\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c&lt;\/button&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<ul>\n<li>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c data \u0438\u043c\u0435\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438, \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0435 \u043e\u0442 \u043d\u0435\u0433\u043e, \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0412\u043e\u043f\u0440\u043e\u0441 \u043a \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>function Button({ onClick, label }) {   console.log(`\u0420\u0435\u043d\u0434\u0435\u0440 \u043a\u043d\u043e\u043f\u043a\u0438: ${label}`);   return &lt;button onClick={onClick}&gt;{label}&lt;\/button&gt;; }  function Counter() {   const [count, setCount] = React.useState(0);    const increment = () =&gt; setCount(count + 1);    return (     &lt;div&gt;       &lt;h1&gt;\u0421\u0447\u0435\u0442\u0447\u0438\u043a: {count}&lt;\/h1&gt;       &lt;Button onClick={increment} label=\"\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c\" \/&gt;     &lt;\/div&gt;   ); } <\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0435 Counter \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f increment (\u0434\u043b\u044f \u043d\u0430\u0441 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e), \u0438 Button \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u043f onClick.<\/p>\n<p><strong>\u0412\u043e\u043f\u0440\u043e\u0441:<\/strong> \u041a\u0430\u043a \u0434\u0443\u043c\u0430\u0435\u0442\u0435, \u0441\u0442\u0430\u043d\u0435\u0442 \u043b\u0438 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c increment \u0432 useCallback \u0438 Button \u0432 React.memo? \u041a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438?<\/p>\n<ol>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c useCallback \u0434\u043b\u044f increment \u0438 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c Button \u0432 React.memo.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043d\u0430\u0434 \u043e\u0442\u0432\u0435\u0442\u043e\u043c, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/strong><\/p>\n<h3>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/h3>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435<\/h4>\n<ul>\n<li>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u041a\u0410\u0416\u0414\u041e\u041c \u0440\u0435\u043d\u0434\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435-\u0440\u0435\u043d\u0434\u0435\u0440\u0435, \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0412\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b<\/h3>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u043f\u0441\u0430 \u0438 \u043e\u0431\u0451\u0440\u043d\u0443\u0442 \u0432 React.memo, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0443 \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437 \u043f\u0440\u043e\u043f\u0441\u043e\u0432 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438, \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0440\u043e\u043f\u0441\u0430\u0445 \u043d\u0435 \u043c\u0435\u043c\u043e\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041e\u0442\u0432\u0435\u0442<\/h4>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 increment \u0432 useCallback \u0438 Button \u0432 React.memo \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438 Button. \u041d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0431\u043e \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043b\u0438\u0431\u043e \u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u043e\u0431\u0449\u0435.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443?<\/h3>\n<ul>\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/strong> \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Button \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0438 \u0432\u0440\u0435\u043c\u044f \u0435\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-444178","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444178","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=444178"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444178\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=444178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=444178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=444178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}