{"id":317523,"date":"2021-02-05T09:00:51","date_gmt":"2021-02-05T09:00:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=317523"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=317523","title":{"rendered":"createRef, setRef, useRef \u0438 \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d current \u0432 ref"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0445\u0430\u0431\u0440!<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u043f\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0441 <code>ref<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0435\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f <code>createRef<\/code> \u043e\u0442 <code>useRef<\/code>, \u0437\u0430\u0447\u0435\u043c \u0432 \u044d\u0442\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>current<\/code> \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u041e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u0445 \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>ref<\/code>, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043a\u043e\u043f\u0438\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b. (<a href=\"https:\/\/youtu.be\/hoQz95Fh84c\" rel=\"noopener noreferrer nofollow\">\u0414\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<h3>\u0412\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c setRef<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u0433\u0434\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 <code>ref<\/code>. \u0412 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435, \u043c\u043e\u0438\u043c \u043b\u044e\u0431\u0438\u043c\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <code>ref<\/code> &#8212; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code>:<\/p>\n<pre><code class=\"javascript\">class App extends Component {   setRef = (ref) =&gt; {     this.ref = ref;   };    componentDidMount() {     console.log(this.ref); \/\/ div   }    render() {     return &lt;div ref={this.setRef}&gt;test&lt;\/div&gt;;   } }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>setRef<\/code> \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043d\u043e\u0434\u0443 \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0435 \u0432 <code>this<\/code>. \u042f \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 <code>setRef<\/code>, \u0442.\u043a. \u043e\u043d \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043c\u043d\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <strong>setter<\/strong>.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0432 \u043d\u0435\u043c \u043f\u043e\u0447\u0442\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u0433\u0438\u044f. \u0412\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0435\u0441\u044c \u043a\u043e\u0434, \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u043a\u0440\u043e\u043c\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code> \u0438 \u043a\u0442\u043e-\u0442\u043e \u0435\u0435 \u0442\u0430\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442, \u043d\u043e \u0438 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>callback<\/strong>.<\/p>\n<pre><code class=\"javascript\">function someFunction(callback) {   doSomething()     .then((data) =&gt; callback(data)); }<\/code><\/pre>\n<h3>\u0412\u043e\u043f\u0440\u043e\u0441\u044b \u043a createRef<\/h3>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0441 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>createRef<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 <code>ref<\/code> \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u0430\u043c \u0436\u0435 \u0432 <code>this<\/code>.<\/p>\n<pre><code class=\"javascript\">class App extends Component {   constructor(props) {     super(props);      this.ref = createRef();   }    componentDidMount() {     console.log(this.ref.current); \/\/ div   }    render() {     return &lt;div ref={this.ref}&gt;test&lt;\/div&gt;;   } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434, \u043d\u0430 \u043c\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, <code>createRef()<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0432 <code>this.ref<\/code>. \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f <code>console.log<\/code>, \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>current<\/code> \u0440\u0430\u0432\u043d\u044b\u043c <code>null<\/code>.<\/p>\n<pre><code class=\"javascript\">this.ref = createRef(); console.log(this.ref); \/\/ { current: null }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442  <code>{ current: null }<\/code> \u0437\u0430\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code> \u0438 \u0443\u0436\u0435 \u0432 <code>componentDidMount<\/code> \u0438\u043c\u0435\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u043e\u0434\u0435.<\/p>\n<p>\u0422\u0443\u0442 \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432: <\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>current<\/code>?<\/p>\n<\/li>\n<li>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0435\u0441\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u043e\u0433\u0434\u0430 \u0432 <code>ref<\/code> \u043c\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c <code>this.ref.current<\/code>?<\/p>\n<\/li>\n<li>\n<p>\u0410 \u0432\u043e\u043e\u0431\u0449\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>current<\/code>?<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 <code>ref<\/code>, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0442\u0430\u043c \u043c\u0443\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d \u0432 <strong>React<\/strong>, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 <strong>redux<\/strong> \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0433\u0434\u0435 \u043c\u0443\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 createRef<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u043e \u0432\u0441\u0435\u043c \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0440\u0435\u0430\u043a\u0442\u0430. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u0435\u0442\u043e\u0434\u0430 <code>createRef()<\/code>(<a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/ReactCreateRef.js#L12\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>).<\/p>\n<pre><code class=\"javascript\">export function createRef(): RefObject {   const refObject = {     current: null,   };   if (__DEV__) {     Object.seal(refObject);   }   return refObject; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>current<\/code> \u0440\u0430\u0432\u043d\u044b\u043c <code>null<\/code>, \u0438 \u043e\u043d \u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f. \u041a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u0430\u0436\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>createRef<\/code> \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>current<\/code>. \u0418 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435.<\/p>\n<pre><code class=\"javascript\">class App extends Component {   constructor(props) {     super(props);      this.ref = { current: null, count: 2 } \/\/ createRef();   }    componentDidMount() {     console.log(this.ref.current); \/\/ div     console.log(this.ref.count); \/\/ 2   }    render() {     return &lt;div ref={this.ref}&gt;test&lt;\/div&gt;;   } }<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>count<\/code> \u0438 \u043e\u043d\u043e \u043d\u0435 \u0438\u0441\u0447\u0435\u0437\u043b\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u043d\u0438\u044f \u0432 <code>ref<\/code>.<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 ref<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 ref, \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c. \u042f \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u0435\u0431\u0430\u0436\u0438\u043b, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u0441\u0442\u043e \u0433\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435\u043c <code>ref<\/code>. \u0418 \u044d\u0442\u043e \u043c\u0435\u0441\u0442\u043e &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberCommitWork.new.js#L987\" rel=\"noopener noreferrer nofollow\">commitAttachRef<\/a>. \u041e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 <strong>react-reconciler<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0435 <strong>ReactFiberCommitWork.new.js<\/strong>.<\/p>\n<pre><code class=\"javascript\">function commitAttachRef(finishedWork: Fiber) {   const ref = finishedWork.ref; \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e \u0447\u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 ref   if (ref !== null) { \/\/ \u0415\u0441\u043b\u0438 \u0432 ref \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438, \u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0435\u0447\u0435\u0433\u043e     const instanceToUse = finishedWork.stateNode; \/\/ \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u0441\u0430\u043c\u0443 \u043d\u043e\u0434\u0443          \/\/ ...          if (typeof ref === 'function') { \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438 ref       \/\/ ...       ref(instanceToUse);     } else {       \/\/ ...       ref.current = instanceToUse;     }   } }<\/code><\/pre>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <code>ref<\/code> \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439<\/p>\n<pre><code class=\"javascript\">this.ref = createRef(); \/\/ { current: null }  &lt;div ref={this.ref}&gt;test&lt;\/div&gt;  if (typeof ref !== 'function') {   ref.current = instanceToUse; }<\/code><\/pre>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u044d\u0442\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0439 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>current<\/code> \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430. \u0427\u0442\u043e\u0431\u044b \u0443\u0436\u0435 \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u044d\u0442\u043e, \u044f \u043f\u043e\u043b\u0435\u0437 \u0432 \u0442\u0438\u043f\u044b:<\/p>\n<pre><code class=\"javascript\">export type RefObject = {|   current: any, |};<\/code><\/pre>\n<p><strong>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435 <\/strong><code>current<\/code><strong> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u0430, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043c\u0435\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0435 <\/strong><code>current<\/code><strong> \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/strong><\/p>\n<h2>\u0410 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 commitAttachRef \u043f\u0440\u0438 2-\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435?<\/h2>\n<p>\u041a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0437\u0443\u0447\u0438\u043b\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 <code>ref<\/code> \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u044b.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442. \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>commitAttachRef<\/code> \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b <code>console.log<\/code><\/p>\n<pre><code class=\"javascript\">function commitAttachRef(finishedWork: Fiber) {   console.log('commitAttachRef !!!');    \/\/ ... }<\/code><\/pre>\n<p>\u0410 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 <code>ref<\/code>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0432\u043d\u0443\u0442\u0440\u0438 <code>div-\u0430<\/code>. \u0418 \u043e\u043f\u0438\u0441\u0430\u043b \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <code>incerement<\/code>.<\/p>\n<pre><code class=\"javascript\">class App extends Component {   constructor(props) {     super(props);          this.ref = createRef();     this.state = { counter: 0 };   }      \/\/ ...      increment = () =&gt; {     this.setState((prevState) =&gt; ({       counter: prevState.counter + 1,     }));   }    render() {     return (       &lt;div ref={this.ref}&gt;         &lt;button onClick={this.increment}&gt;+&lt;\/button&gt;         &lt;span&gt;{this.state.counter}&lt;\/span&gt;       &lt;\/div&gt;     );   } }<\/code><\/pre>\n<p>\u0412 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0436\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a0f\/5a0\/a04\/a0f5a0a047632b5e807dccc238ceb3c3.jpg\" width=\"1678\" height=\"932\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>console.log('commitAttachRef !!!')<\/code>. \u0418 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430, \u043d\u043e \u043c\u0435\u0442\u043e\u0434 <code>commitAttachRef<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0432 <code>className<\/code> \u044d\u0442\u043e\u0433\u043e <code>div-\u0430<\/code><\/p>\n<pre><code class=\"javascript\">return (   &lt;div ref={this.ref} className={`class-${this.state.counter}`}&gt;     &lt;button onClick={this.increment}&gt;+&lt;\/button&gt;     &lt;span&gt;{this.state.counter}&lt;\/span&gt;   &lt;\/div&gt; );<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <code>commitAttachRef<\/code> \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c 1 \u0440\u0430\u0437<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0435\u0449\u0435 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u043e\u0434, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0440\u044f\u0434\u043e\u043c \u0441 <code>div-\u043e\u043c<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0430\u0443\u043d\u0442\u0438\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0447\u0435\u0442\u043d\u043e\u0435.<\/p>\n<pre><code class=\"javascript\">return (   &lt;&gt;     &lt;button onClick={this.increment}&gt;+&lt;\/button&gt;     &lt;span&gt;{this.state.counter}&lt;\/span&gt;     {this.state.counter % 2 === 0 &lt;div ref={this.ref}&gt;test&lt;\/div&gt;}   &lt;\/&gt; )<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440. \u0418 \u043f\u043e\u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0441\u043d\u043e\u0432\u0430 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u201c\u043f\u043b\u044e\u0441\u201d. \u0418 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 \u0447\u0438\u0441\u043b\u043e \u0447\u0435\u0442\u043d\u043e\u0435, \u043f\u0435\u0440\u0435\u0434 <strong>did update<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>\u201ccommitAttachRef !!!\u201d<\/code>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/610\/6bc\/94d\/6106bc94dd09fe0ef5a3a38cac5c1b80.jpg\" width=\"1680\" height=\"929\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e. \u041f\u043e\u043a\u0430 \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043d\u043e\u0434\u0430 \u043c\u0443\u0442\u0438\u0440\u0443\u0435\u0442 \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c <code>ref<\/code> \u0440\u0435\u0430\u043a\u0442\u0443 \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435\u0442, \u0442.\u043a. \u0441\u0441\u044b\u043b\u043a\u0430 \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <strong>Mount \/ Unmount<\/strong> \u043d\u043e\u0434\u044b, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043d\u043e\u0434\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>ref<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u0435\u0442\u043e\u0434 <code>commitAttachRef<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043d\u043e\u0434\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043d\u043e \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<h2>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c createRef \u0432\u043c\u0435\u0441\u0442\u043e useRef?<\/h2>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445 \u043c\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>createRef()<\/code> \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430\u0445, \u0430 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0435\u0441\u043b\u0438 <code>createRef()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \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?<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0445\u0443\u043a\u0430\u0445. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430:<\/p>\n<pre><code class=\"javascript\">const App = () =&gt; {   const [counter, setCounter] = useState(0);   const ref = createRef(); \/\/ useRef();      const increment = () =&gt; setCounter(counter =&gt; counter + 1);      useEffect(() =&gt; {     console.log(\"[useEffect] counter = \", counter, ref.current);   }, [counter]);      return (     &lt;div ref={ref}&gt;       &lt;button onClick={increment}&gt;+&lt;\/button&gt;       &lt;span&gt;{counter}&lt;\/span&gt;     &lt;\/div&gt;   ); }<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e <code>useRef()<\/code> \u043c\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043c <code>createRef()<\/code>. \u0418 \u0432 <code>useEffect<\/code> \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f <code>counter<\/code> \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>counter<\/code> \u0438 <code>ref<\/code>. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1fb\/a43\/132\/1fba431328ad941445c8cd28a1134411.jpg\" width=\"1679\" height=\"936\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>commitAttachRef<\/code>. \u0425\u043e\u0442\u044f \u043d\u043e\u0434\u0443, \u043a\u0430\u043a \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445,  \u043c\u044b \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 <code>useEffect<\/code> \u043d\u043e\u0434\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u0430\u044f, \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 <code>&lt;div&gt;<\/code><\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043c <code>createRef<\/code> \u043d\u0430 <code>useRef<\/code>, \u0442\u043e\u0433\u0434\u0430 <code>commitAttachRef<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043e\u0431\u043e\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 useRef<\/h2>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 <code>createRef<\/code> \u043c\u044b \u0443\u0436\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0435\u0433\u043b\u043e \u0438\u0437\u0443\u0447\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 <code>useRef<\/code>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0447\u0438\u0442\u0430\u043b\u0438 \u043c\u043e\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u201c<a href=\"https:\/\/habr.com\/en\/post\/537410\/\" rel=\"noopener noreferrer nofollow\">\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<\/a>\u201d \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0437\u0430 \u043e\u0434\u043d\u0438\u043c \u0445\u0443\u043a\u043e\u043c <code>useRef<\/code> \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e <code>mountRef<\/code>, <code>updateRef<\/code>. \u041e\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0435.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0440\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#L1283\" rel=\"noopener noreferrer nofollow\">mountRef<\/a>:<\/p>\n<pre><code class=\"javascript\">function mountRef&lt;T&gt;(initialValue: T): {|current: T|} {   const hook = mountWorkInProgressHook();    if (_DEV_) {     \/\/ ...   } else {     const ref = {current: initialValue};     hook.memoizedState = ref;     return ref;   } }   <\/code><\/pre>\n<p>\u0412 <code>mountRef<\/code> \u0434\u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441 <code>hook<\/code>. \u0418 \u0434\u0430\u043b\u0435\u0435 \u0432\u0438\u0434\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 dev \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435. \u0418 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u043a\u0440\u043e\u043b\u0438\u043c \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u043b\u043e\u043a \u0434\u043b\u044f \u0434\u0435\u0432 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0434 \u0440\u0435\u0436\u0438\u043c\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u043e 3 \u0441\u0442\u0440\u043e\u043a\u0438: \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>ref<\/code>, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0445\u0443\u043a\u0430 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1355\" rel=\"noopener noreferrer nofollow\">updateRef<\/a> \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435:<\/p>\n<pre><code class=\"javascript\">function updateRef&lt;T&gt;(initialValue: T): {|current: T|} {   const hook = updateWorkInProgressHook();   return hook.memoizedState; }<\/code><\/pre>\n<p>\u041d\u0443\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0445\u0443\u043a \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>updateWorkInProgressHook()<\/code> \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0432 \u043d\u0435\u043c <code>ref<\/code>.<\/p>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 createRef \u0438 useRef<\/h2>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u0445\u0443\u043a <code>useRef<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 <code>useRef<\/code> \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0447\u0435\u043c <code>createRef<\/code>. \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0447\u043d\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u044f \u0445\u043e\u0447\u0443 \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u0435 \u043a\u0430\u043a\u0438\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u044f \u0440\u0435\u0448\u0438\u043b \u0432\u0432\u0435\u0441\u0442\u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u043a\u0432\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0431\u0443\u043a\u0432\u0430 \u0432\u043e\u0437\u043b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0435\u0439, \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u0442\u043e \u0442\u0430 \u0436\u0435 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0431\u0443\u043a\u0432\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/11a\/82f\/098\/11a82f0982969f7f8d18174be03ba6d0.jpg\" width=\"1514\" height=\"917\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0448\u043a\u0430\u043b\u0443 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f <code>useRef()<\/code> \u0438 <code>createRef()<\/code><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/581\/5d6\/220\/5815d622052c8efec434b15dd2d2f0fc.jpg\" width=\"1115\" height=\"932\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0443 \u043e\u0431\u043e\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435, \u0430 \u0432\u043e\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0443\u0436\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 <code>useRef()<\/code> \u0432 <code>current<\/code> \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0432\u0441\u0435 \u0442\u0443 \u0436\u0435 \u043d\u043e\u0434\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u043d\u0430 <code>div<\/code>, \u0434\u0430 \u0438 \u0441\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 <code>current<\/code> \u0432\u0441\u0435 \u0442\u043e\u0442 \u0436\u0435 &#171;a&#187;. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 <code>createRef()<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 &#171;c&#187; (\u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u0431\u044b\u043b &#171;b&#187;), \u0442\u0430\u043a \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>current<\/code> \u0441\u043d\u043e\u0432\u0430 \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f <code>null<\/code>.  \u0418 \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>commitAttachRef<\/code> \u0438 \u043d\u0430 2-\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435.<\/p>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0440\u0435\u0437\u043e\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441. \u0410 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>commitAttachRef<\/code>? \u042d\u0442\u043e \u0442\u043e \u0447\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u0441 &#171;b&#187; \u043d\u0430 &#171;\u0441&#187; \u0438\u043b\u0438 \u044d\u0442\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 <code>current<\/code> \u0441\u043d\u043e\u0432\u0430 \u0441\u0442\u0430\u043b <code>null<\/code>? <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u0433\u0430\u0434\u043a\u0438 \u044d\u0442\u043e\u0439 \u0442\u0430\u0439\u043d\u044b, \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c 2 \u043c\u0435\u043b\u043a\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430:<\/p>\n<h3>\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 1. \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0442\u0443 \u0436\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c current<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code>const App = () =&gt; {   const [counter, setCounter] = useState(0);   const ref = useRef();    \/\/ ...    ref.current = null;    return (     &lt;div ref={ref}&gt;       &lt;button onClick={increment&gt;+&lt;\/button&gt;       &lt;span&gt;{counter}&lt;\/span&gt;     &lt;\/div&gt;   ) }<\/code><\/pre>\n<p>\u0421\u0443\u0442\u044c \u0438\u0434\u0435\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 1-\u043e\u043c, 2-\u043e\u043c \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u0445, \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c <code>current<\/code> \u0440\u0430\u0432\u043d\u044b\u0439 <code>null<\/code>. \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f <code>commitAttachRef<\/code> \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0435\u0434\u0435\u0440\u0435.<\/p>\n<p><strong>\u0420\u0415\u0417\u0423\u041b\u042c\u0422\u0410\u0422<\/strong>: <code>commitAttachRef<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c 1 \u0440\u0430\u0437, \u043f\u0440\u0438 \u043c\u0430\u0443\u043d\u0442\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<h3>\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 2. \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c current<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">const App = () =&gt; {   const [counter, setCounter] = useState(0);   const ref = useRef();   const testRef = { current: ref.current };      \/\/ ...      useEffect(() =&gt; {     ref.current = testRef.current;   });    return (     &lt;div ref={testRef}&gt;       &lt;button onClick={increment}&gt;+&lt;\/button&gt;       &lt;span&gt;{counter}&lt;\/span&gt;     &lt;\/div&gt;   ) }<\/code><\/pre>\n<p>\u0418\u0434\u0435\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code>, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>current<\/code>. <\/p>\n<p><strong>\u0420\u0415\u0417\u0423\u041b\u042c\u0422\u0410\u0422<\/strong>: <strong>commitAttachRef<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440<\/p>\n<h3>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043c\u0443\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c<\/h3>\n<p>\u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 <code>commitAttachRef<\/code> \u0432\u043b\u0438\u044f\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u043e\u0441\u043b\u0430\u043b\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code>. \u0418 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043b\u0438 <strong>React Core<\/strong> \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.<\/p>\n<p><code>useRef<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043b\u0438\u0448\u044c \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b, \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <code>commitAttachRef<\/code>. \u0418 \u044d\u0442\u0443 \u0441\u0441\u044b\u043b\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 <code>useEffect<\/code>, \u0438 \u0434\u0430\u0436\u0435 <strong>eslint<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0432\u0441\u0435 \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0438, \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c <code>ref<\/code> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0442.\u043a. \u0441\u0441\u044b\u043b\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430\u044f, \u0445\u043e\u0442\u044c <code>current<\/code> \u043c\u043e\u0436\u0435\u0442 \u0438 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f. \u0410 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <code>useEffect<\/code>, \u0435\u0441\u043b\u0438 <code>current<\/code> \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u043d\u043e \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>ref.current<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b <code>useEffect<\/code><strong> <\/strong>(\u043d\u043e <strong>eslint<\/strong> \u043d\u0430 \u0442\u0430\u043a\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>ref.current<\/code> \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f, \u0442.\u043a. \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u0441\u043a\u043e\u0440\u0435\u0435 \u043a \u0431\u0430\u0433\u0430\u043c, \u0447\u0435\u043c \u043a \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u0435). \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0442\u0435\u0440\u043d \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 <code>ref<\/code> \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u043a <code>props<\/code>. \u0418 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 <code>current<\/code>, \u0432\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>current<\/code>, \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c, \u0430 \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043c <strong>React Core<\/strong> \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.<\/p>\n<h2>\u041c\u044b\u0441\u043b\u0438 \u0432\u0441\u043b\u0443\u0445<\/h2>\n<p>\u0418\u0434\u0435\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; \u044d\u0442\u043e \u0447\u0443\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0432\u043a\u0430\u043b\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0433\u0432\u043e\u0437\u0434\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u0414\u0430, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u0430\u043b\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0432\u044b \u043d\u0430\u0447\u043d\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u0430\u043a \u0442\u043e \u0438\u043d\u0430\u0447\u0435, \u043d\u043e \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0441\u0442\u0430\u043d\u0435\u0442\u0435 \u0431\u043e\u043b\u0435\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u0432\u0430\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0442.\u043a. \u0431\u0443\u0434\u0435\u0442\u0435 \u043e\u0441\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c. \u0418 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0432\u0430\u0441 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 <code>current<\/code> \u0432 <code>ref<\/code>, \u0442.\u043a. \u044d\u0442\u043e \u0436\u0435\u0440\u0442\u0432\u0430 \u0432\u043e \u0438\u043c\u044f \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438.<br \/>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0442\u043e \u0447\u0442\u043e \u044f \u0434\u0435\u043b\u0430\u044e, \u043c\u043e\u0436\u0435\u0442\u0435 \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> \ud83d\ude42 <\/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\/540442\/\"> https:\/\/habr.com\/ru\/post\/540442\/<\/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 \u0445\u0430\u0431\u0440!<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u043f\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0441 <code>ref<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0435\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f <code>createRef<\/code> \u043e\u0442 <code>useRef<\/code>, \u0437\u0430\u0447\u0435\u043c \u0432 \u044d\u0442\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>current<\/code> \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u041e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u0445 \u044f\u0449\u0438\u043a\u043e\u0432 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>ref<\/code>, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043a\u043e\u043f\u0438\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b. (<a href=\"https:\/\/youtu.be\/hoQz95Fh84c\" rel=\"noopener noreferrer nofollow\">\u0414\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<h3>\u0412\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c setRef<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u0433\u0434\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 <code>ref<\/code>. \u0412 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435, \u043c\u043e\u0438\u043c \u043b\u044e\u0431\u0438\u043c\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <code>ref<\/code> &#8212; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code>:<\/p>\n<pre><code class=\"javascript\">class App extends Component {   setRef = (ref) =&gt; {     this.ref = ref;   };    componentDidMount() {     console.log(this.ref); \/\/ div   }    render() {     return &lt;div ref={this.setRef}&gt;test&lt;\/div&gt;;   } }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>setRef<\/code> \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043d\u043e\u0434\u0443 \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0435 \u0432 <code>this<\/code>. \u042f \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 <code>setRef<\/code>, \u0442.\u043a. \u043e\u043d \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043c\u043d\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <strong>setter<\/strong>.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0432 \u043d\u0435\u043c \u043f\u043e\u0447\u0442\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u0433\u0438\u044f. \u0412\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0435\u0441\u044c \u043a\u043e\u0434, \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u043a\u0440\u043e\u043c\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code> \u0438 \u043a\u0442\u043e-\u0442\u043e \u0435\u0435 \u0442\u0430\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442, \u043d\u043e \u0438 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>callback<\/strong>.<\/p>\n<pre><code class=\"javascript\">function someFunction(callback) {   doSomething()     .then((data) =&gt; callback(data)); }<\/code><\/pre>\n<h3>\u0412\u043e\u043f\u0440\u043e\u0441\u044b \u043a createRef<\/h3>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0441 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>createRef<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 <code>ref<\/code> \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u0430\u043c \u0436\u0435 \u0432 <code>this<\/code>.<\/p>\n<pre><code class=\"javascript\">class App extends Component {   constructor(props) {     super(props);      this.ref = createRef();   }    componentDidMount() {     console.log(this.ref.current); \/\/ div   }    render() {     return &lt;div ref={this.ref}&gt;test&lt;\/div&gt;;   } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434, \u043d\u0430 \u043c\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, <code>createRef()<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0432 <code>this.ref<\/code>. \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f <code>console.log<\/code>, \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>current<\/code> \u0440\u0430\u0432\u043d\u044b\u043c <code>null<\/code>.<\/p>\n<pre><code class=\"javascript\">this.ref = createRef(); console.log(this.ref); \/\/ { current: null }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442  <code>{ current: null }<\/code> \u0437\u0430\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>ref<\/code> \u0438 \u0443\u0436\u0435 \u0432 <code>componentDidMount<\/code> \u0438\u043c\u0435\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u043e\u0434\u0435.<\/p>\n<p>\u0422\u0443\u0442 \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432: <\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>current<\/code>?<\/p>\n<\/li>\n<li>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0435\u0441\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u043e\u0433\u0434\u0430 \u0432 <code>ref<\/code> \u043c\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c <code>this.ref.current<\/code>?<\/p>\n<\/li>\n<li>\n<p>\u0410 \u0432\u043e\u043e\u0431\u0449\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>current<\/code>?<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 <code>ref<\/code>, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0442\u0430\u043c \u043c\u0443\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d \u0432 <strong>React<\/strong>, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 <strong>redux<\/strong> \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0433\u0434\u0435 \u043c\u0443\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 createRef<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u043e \u0432\u0441\u0435\u043c \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0440\u0435\u0430\u043a\u0442\u0430. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u0435\u0442\u043e\u0434\u0430 <code>createRef()<\/code>(<a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react\/src\/ReactCreateRef.js#L12\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>).<\/p>\n<pre><code class=\"javascript\">export function createRef(): RefObject {   const refObject = {     current: null,   };   if (__DEV__) {     Object.seal(refObject);   }   return refObject; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>current<\/code> \u0440\u0430\u0432\u043d\u044b\u043c <code>null<\/code>, \u0438 \u043e\u043d \u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f. \u041a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u0430\u0436\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>createRef<\/code> \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>current<\/code>. \u0418 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435.<\/p>\n<pre><code class=\"javascript\">class App extends Component {   constructor(props) {     super(props);      this.ref = { current: null, count: 2 } \/\/ createRef();   }    componentDidMount() {     console.log(this.ref.current); \/\/ div     console.log(this.ref.count); \/\/ 2   }    render() {     return &lt;div ref={this.ref}&gt;test&lt;\/div&gt;;   } }<\/code><\/pre>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>count<\/code> \u0438 \u043e\u043d\u043e \u043d\u0435 \u0438\u0441\u0447\u0435\u0437\u043b\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u043d\u0438\u044f \u0432 <code>ref<\/code>.<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 ref<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 ref, \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c. \u042f \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u0435\u0431\u0430\u0436\u0438\u043b, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u0441\u0442\u043e \u0433\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435\u043c <code>ref<\/code>. \u0418 \u044d\u0442\u043e \u043c\u0435\u0441\u0442\u043e &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberCommitWork.new.js#L987\" rel=\"noopener noreferrer nofollow\">commitAttachRef<\/a>. \u041e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 <strong>react-reconciler<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0435 <strong>ReactFiberCommitWork.new.js<\/strong>.<\/p>\n<pre><code class=\"javascript\">function commitAttachRef(finishedWork: Fiber) {   const ref = finishedWork.ref; \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e \u0447\u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 ref   if (ref !== null) { \/\/ \u0415\u0441\u043b\u0438 \u0432 ref \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438, \u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0435\u0447\u0435\u0433\u043e     const instanceToUse = finishedWork.stateNode; \/\/ \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u0441\u0430\u043c\u0443 \u043d\u043e\u0434\u0443          \/\/ ...          if (typeof ref === 'function') { \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438 ref       \/\/ ...       ref(instanceToUse);     } else {       \/\/ ...       ref.current = instanceToUse;     }   } }<\/code><\/pre>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <code>ref<\/code> \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439<\/p>\n<pre><code class=\"javascript\">this.ref = createRef(); \/\/ { current: null }  &lt;div ref={this.ref}&gt;test&lt;\/div&gt;  if (typeof ref !== 'function') {   ref.current = instanceToUse; }<\/code><\/pre>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u044d\u0442\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0439 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>current<\/code> \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430. \u0427\u0442\u043e\u0431\u044b \u0443\u0436\u0435 \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u044d\u0442\u043e, \u044f \u043f\u043e\u043b\u0435\u0437 \u0432 \u0442\u0438\u043f\u044b:<\/p>\n<pre><code class=\"javascript\">export type RefObject = {|   current: any, |};<\/code><\/pre>\n<p><strong>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435 <\/strong><code>current<\/code><strong> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u0430, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043c\u0435\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0435 <\/strong><code>current<\/code><strong> \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/strong><\/p>\n<h2>\u0410 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 commitAttachRef \u043f\u0440\u0438 2-\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435?<\/h2>\n<p>\u041a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0437\u0443\u0447\u0438\u043b\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 <code>ref<\/code> \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u044b.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442. \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>commitAttachRef<\/code> \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b <code>console.log<\/code><\/p>\n<pre><code class=\"javascript\">function commitAttachRef(finishedWork: Fiber) {   console.log('commitAttachRef !!!');    \/\/ ... }<\/code><\/pre>\n<p>\u0410 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 <code>ref<\/code>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0432\u043d\u0443\u0442\u0440\u0438 <code>div-\u0430<\/code>. \u0418 \u043e\u043f\u0438\u0441\u0430\u043b \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <code>incerement<\/code>.<\/p>\n<pre><code class=\"javascript\">class App extends Component {   constructor(props) {     super(props);          this.ref = createRef();     this.state = { counter: 0 };   }      \/\/ ...      increment = () =&gt; {     this.setState((prevState) =&gt; ({       counter: prevState.counter + 1,     }));   }    render() {     return (       &lt;div ref={this.ref}&gt;         &lt;button onClick={this.increment}&gt;+&lt;\/button&gt;         &lt;span&gt;{this.state.counter}&lt;\/span&gt;       &lt;\/div&gt;     );   } }<\/code><\/pre>\n<p>\u0412 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0436\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>console.log('commitAttachRef !!!')<\/code>. \u0418 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430, \u043d\u043e \u043c\u0435\u0442\u043e\u0434 <code>commitAttachRef<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0432 <code>className<\/code> \u044d\u0442\u043e\u0433\u043e <code>div-\u0430<\/code><\/p>\n<pre><code class=\"javascript\">return (   &lt;div ref={this.ref} className={`class-${this.state.counter}`}&gt;     &lt;button onClick={this.increment}&gt;+&lt;\/button&gt;     &lt;span&gt;{this.state.counter}&lt;\/span&gt;   &lt;\/div&gt; );<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <code>commitAttachRef<\/code> \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c 1 \u0440\u0430\u0437<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0435\u0449\u0435 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u043e\u0434, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0440\u044f\u0434\u043e\u043c \u0441 <code>div-\u043e\u043c<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0430\u0443\u043d\u0442\u0438\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0447\u0435\u0442\u043d\u043e\u0435.<\/p>\n<pre><code class=\"javascript\">return (   &lt;&gt;     &lt;button onClick={this.increment}&gt;+&lt;\/button&gt;     &lt;span&gt;{this.state.counter}&lt;\/span&gt;     {this.state.counter % 2 === 0 &lt;div ref={this.ref}&gt;test&lt;\/div&gt;}   &lt;\/&gt; )<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440. \u0418 \u043f\u043e\u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0441\u043d\u043e\u0432\u0430 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u201c\u043f\u043b\u044e\u0441\u201d. \u0418 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 \u0447\u0438\u0441\u043b\u043e \u0447\u0435\u0442\u043d\u043e\u0435, \u043f\u0435\u0440\u0435\u0434 <strong>did update<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>\u201ccommitAttachRef !!!\u201d<\/code>.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e. \u041f\u043e\u043a\u0430 \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043d\u043e\u0434\u0430 \u043c\u0443\u0442\u0438\u0440\u0443\u0435\u0442 \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c <code>ref<\/code> \u0440\u0435\u0430\u043a\u0442\u0443 \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435\u0442, \u0442.\u043a. \u0441\u0441\u044b\u043b\u043a\u0430 \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <strong>Mount \/ Unmount<\/strong> \u043d\u043e\u0434\u044b, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043d\u043e\u0434\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>ref<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u0435\u0442\u043e\u0434 <code>commitAttachRef<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043d\u043e\u0434\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043d\u043e \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<h2>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c createRef \u0432\u043c\u0435\u0441\u0442\u043e useRef?<\/h2>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445 \u043c\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>createRef()<\/code> \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430\u0445, \u0430 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0435\u0441\u043b\u0438 <code>createRef()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \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?<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0445\u0443\u043a\u0430\u0445. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430:<\/p>\n<pre><code class=\"javascript\">const App = () =&gt; {   const [counter, setCounter] = useState(0);   const ref = createRef(); \/\/ useRef();      const increment = () =&gt; setCounter(counter =&gt; counter + 1);      useEffect(() =&gt; {     console.log(\"[useEffect] counter = \", counter, ref.current);   }, [counter]);      return (     &lt;div ref={ref}&gt;       &lt;button onClick={increment}&gt;+&lt;\/button&gt;       &lt;span&gt;{counter}&lt;\/span&gt;     &lt;\/div&gt;   ); }<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e <code>useRef()<\/code> \u043c\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043c <code>createRef()<\/code>. \u0418 \u0432 <code>useEffect<\/code> \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f <code>counter<\/code> \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>counter<\/code> \u0438 <code>ref<\/code>. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>commitAttachRef<\/code>. \u0425\u043e\u0442\u044f \u043d\u043e\u0434\u0443, \u043a\u0430\u043a \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445,  \u043c\u044b \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 <code>useEffect<\/code> \u043d\u043e\u0434\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u0430\u044f, \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 <code>&lt;div&gt;<\/code><\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043c <code>createRef<\/code> \u043d\u0430 <code>useRef<\/code>, \u0442\u043e\u0433\u0434\u0430 <code>commitAttachRef<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043e\u0431\u043e\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c<\/p>\n<h2>\u0418\u0437\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 useRef<\/h2>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 <code>createRef<\/code> \u043c\u044b \u0443\u0436\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0435\u0433\u043b\u043e \u0438\u0437\u0443\u0447\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 <code>useRef<\/code>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0447\u0438\u0442\u0430\u043b\u0438 \u043c\u043e\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u201c<a href=\"https:\/\/habr.com\/en\/post\/537410\/\" rel=\"noopener noreferrer nofollow\">\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<\/a>\u201d \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0437\u0430 \u043e\u0434\u043d\u0438\u043c \u0445\u0443\u043a\u043e\u043c <code>useRef<\/code> \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e <code>mountRef<\/code>, <code>updateRef<\/code>. \u041e\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0435.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0440\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#L1283\" rel=\"noopener noreferrer nofollow\">mountRef<\/a>:<\/p>\n<pre><code class=\"javascript\">function mountRef&lt;T&gt;(initialValue: T): {|current: T|} {   const hook = mountWorkInProgressHook();    if (_DEV_) {     \/\/ ...   } else {     const ref = {current: initialValue};     hook.memoizedState = ref;     return ref;   } }   <\/code><\/pre>\n<p>\u0412 <code>mountRef<\/code> \u0434\u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441 <code>hook<\/code>. \u0418 \u0434\u0430\u043b\u0435\u0435 \u0432\u0438\u0434\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 dev \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435. \u0418 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u043a\u0440\u043e\u043b\u0438\u043c \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u043b\u043e\u043a \u0434\u043b\u044f \u0434\u0435\u0432 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0434 \u0440\u0435\u0436\u0438\u043c\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u043e 3 \u0441\u0442\u0440\u043e\u043a\u0438: \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>ref<\/code>, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0445\u0443\u043a\u0430 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/facebook\/react\/blob\/master\/packages\/react-reconciler\/src\/ReactFiberHooks.new.js#L1355\" rel=\"noopener noreferrer nofollow\">updateRef<\/a> \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435:<\/p>\n<pre><code class=\"javascript\">function updateRef&lt;T&gt;(initialValue: T): {|current: T|} {   const hook = updateWorkInProgressHook();   return hook.memoizedState; }<\/code><\/pre>\n<p>\u041d\u0443\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0445\u0443\u043a \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>updateWorkInProgressHook()<\/code> \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0432 \u043d\u0435\u043c <code>ref<\/code>.<\/p>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 createRef \u0438 useRef<\/h2>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u0445\u0443\u043a <code>useRef<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 <code>useRef<\/code> \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0447\u0435\u043c <code>createRef<\/code>. \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a<\/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-317523","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317523","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=317523"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317523\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}