{"id":350235,"date":"2023-07-13T21:01:07","date_gmt":"2023-07-13T21:01:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350235"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350235","title":{"rendered":"<span>Mobx: \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0442\u043e\u0440\u043e\u0432 (state manager)<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h4>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Mobx?<\/h4>\n<p>Mobx\u00a0\u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0434\u0430\u044e\u0449\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f\u00a0\u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<p>Mobx \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0430\u044f \u0432\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u0432\u00a0\u0441\u0432\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Context API \u0438, \u043f\u043e\u00a0\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441\u00a0Redux, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0430\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f\u00a0\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u043e\u0440\u0430.<\/p>\n<p>Mobx \u0441\u0442\u043e\u0440\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0434\u043b\u044f\u00a0\u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u043c\u0435\u0449\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u044c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0441\u0442\u043e\u0440\u0430.<\/p>\n<h4>\u0417\u0430\u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u044b?<\/h4>\n<p>\u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u043e\u0440 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432\u00a0\u0441\u0442\u043e\u0440\u0430\u0445 \u0443\u0434\u043e\u0431\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b\u00a0\u2014 \u0431\u0443\u0434\u044c \u0442\u043e api\u2011\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438\u00a0\u043f\u0430\u0440\u0441\u0435\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445\u00a0\u2014 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u00a0\u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445, \u043d\u043e\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043f\u043e\u00a0\u0434\u0435\u0440\u0435\u0432\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u043e\u0442\u043e\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0431\u0435\u0437\u00a0\u0438 \u0441\u00a0Mobx \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043d\u0430\u00a0\u0441\u043b\u0430\u0439\u0434\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/971\/6e9\/f06\/9716e9f06555afddd38d5c0e3ddb6b4b.png\" width=\"1834\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/971\/6e9\/f06\/9716e9f06555afddd38d5c0e3ddb6b4b.png\"\/><\/figure>\n<h4>\u0418\u0437 \u0447\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 Mobx \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/h4>\n<p>Mobx \u0441\u0442\u043e\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437\u00a0\u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439\u00a0\u2014 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430 \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430\u00a0\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438 \u0438 \u0437\u0430\u00a0\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0442\u043e\u0440. \u0422\u0430\u043a\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f\u00a0\u0441\u0442\u043e\u0440\u0430. \u0410\u00a0\u0432\u00a0\u0444\u0430\u0439\u043b\u0435 \u0441\u00a0\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0445\u0443\u043a \u0434\u043b\u044f\u00a0\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430 \u0432\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435.<\/p>\n<p>\u0421\u0442\u043e\u0440 \u0432\u00a0\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u2011\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u043e\u00a0\u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430, \u0438 \u043f\u0440\u0438\u00a0\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u044d\u0442\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e DOM.<\/p>\n<p>\u0424\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u00a0\u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0441\u0442\u043e\u0440\u0430, \u0444\u0430\u0439\u043b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u0442, \u043d\u043e\u00a0\u0438\u0437\u00a0\u043d\u0435\u0433\u043e \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0445\u0443\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0432\u00a0\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0442\u043e\u0440.<\/p>\n<p>\u0418\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u044b\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0442\u043e\u0440\u0430, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u043e\u00a0\u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e\u00a0\u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438\u0437\u00a0\u043d\u0435\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u0442.<\/p>\n<h4>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b<\/h4>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Mobx \u0432 react-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c:<\/p>\n<pre><code class=\"bash\">npm i mobx mobx-react-lite<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0441\u0442\u043e\u0440, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u0430\u043f\u043a\u0443 stores, \u0438 \u0432 \u043d\u0435\u0439 \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430 &#8212; AppStore. \u0412 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 &#8212; \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0434\u043b\u044f \u043e\u0431\u044c\u0435\u043a\u0442\u0430-\u0441\u0442\u043e\u0440\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0443 index.js, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 AppStore \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443.<\/p>\n<p>\u0424\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0442\u043e\u0440\u0430, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p><strong>\/stores<\/strong><\/p>\n<p><strong>\u00a0\u00a0  \/AppStore<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0    AppStoreProvider.jsx<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0    AppStore.js<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0    index.js<\/strong><\/p>\n<h4>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0441\u0442\u043e\u0440\u0430<\/h4>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u044c\u044f\u0432\u0438\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0438 \u0441\u0442\u043e\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f test \u0438 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f toggleTest:<\/p>\n<p><strong>AppStoreProvider.jsx<\/strong><\/p>\n<pre><code class=\"javascript\">import { createContext, useContext } from 'react'; import { observer, useLocalObservable } from 'mobx-react-lite'; import { createAppStore } from '.\/AppStore';  const Context = createContext(null);  export const AppStoreProvider = observer(({ children, ...props }) => {   const store = useLocalObservable(() => createAppStore(props));   return &lt;Context.Provider value={store}>{children}&lt;\/Context.Provider>; });  export const useAppStore = () => {   const store = useContext(Context);   if (!store) throw new Error('Use App store within provider!');   return store; };<\/code><\/pre>\n<p><strong>AppStore.js<\/strong><\/p>\n<pre><code class=\"javascript\">export const createAppStore = (props) => {   return {     test: props.test || 'Hello world',     toggleTest: function () {       this.test = this.test === 'Hi!' ? 'How are you?' : 'Hi!';     },       }; };<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0441\u0442\u043e\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u043e\u0440, \u0432\u00a0\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f\u00a0\u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430.<\/p>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0433\u0434\u0435 \u0443\u0433\u043e\u0434\u043d\u043e, \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440 \u0438\u043c\u0435\u043b \u043d\u0430\u00a0\u043a\u0430\u043a\u043e\u043c \u0442\u043e \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0432\u043e\u0438\u043c \u043f\u0440\u0435\u0434\u043a\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u0412\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043b\u0443\u0447\u0448\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432\u00a0\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043d\u0430\u00a0\u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">import React, {} from 'react'; import {AppStoreProvider} from '~store\/AppStore'; \/\/ index.jsx import {MyComponent} from '.\/MyComponent';  export const App = () => {   return (     &lt;AppStoreProvider>       &lt;MyComponent \/>     &lt;\/AppStoreProvider>   ); }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f\u00a0\u0441\u0442\u043e\u0440\u0430:<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440 \u0432\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435.<\/p>\n<p>\u0414\u043b\u044f\u00a0\u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043b\u0441\u044f \u043f\u0440\u0438\u00a0\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u043e\u0440\u0430, \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u044e observer \u0438\u0437\u00a0\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 mobx\u2011react\u2011lite.<\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u043e\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0438\u0437\u00a0\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u0445\u0443\u043a\u0430 useAppStore:<\/p>\n<pre><code class=\"javascript\">import React from 'react'; import {observer} from 'mobx-react-lite'; import {useAppStore} from '~store\/AppStore'; \/\/ index.jsx  export const MyComponent = observer(() => {   const appStore = useAppStore();    return (     &lt;>       &lt;h1>{appStore.test}&lt;\/h1>       &lt;button onClick={() => appStore.toggleTest()}>Toggle&lt;\/button>     &lt;\/>   ); });<\/code><\/pre>\n<h4>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/h4>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e Mobx \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043b\u044f\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0414\u043e\u0441\u0442\u0443\u043f \u043a\u00a0\u043d\u0435\u0431\u0443 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u00a0\u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0435\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 useState \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0437\u0430\u00a0\u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0422\u0430\u043a\u0436\u0435 \u0432\u00a0\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0414\u043b\u044f\u00a0\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435: <\/p>\n<pre><code class=\"javascript\">const localStore = useLocalStore();<\/code><\/pre>\n<p>\u0418 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0441\u0430\u043c\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0444\u0430\u0439\u043b\u0435:<\/p>\n<pre><code class=\"javascript\">import { useLocalObservable } from 'mobx-react-lite';  const createLocalStore = (props) => {   return {     hello: props.hello || 'Hello world',     toggleHello: function () {       this.hello = this.hello !== 'Hi!' ? 'How are you?' : 'Hi!';     },       }; };  export const useLocalStore = (props = {}) => {   return useLocalObservable(() => createLocalStore(props)); };<\/code><\/pre>\n<h4>\u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433<\/h4>\n<p>\u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044c\u044f\u0432\u0438\u0442\u044c mobx \u0441\u0442\u043e\u0440 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435.<\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e, \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c Mobx \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0442\u044e \u0441 Redux \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 &#8212; \u043a\u0430\u043a \u0432 \u043e\u0431\u044c\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0442\u0430\u043a \u0438 \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0438 \u0441\u0442\u043e\u0440\u043e\u0432. \u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 Mobx \u043f\u0440\u043e\u0441\u0442\u0430\u044f &#8212; \u043e\u0431\u044c\u044f\u0432\u043b\u044f\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0441\u0442\u043e\u0440\u0435 \u0438 \u0434\u043e\u0441\u0442\u0430\u0435\u0442\u0435 \u0435\u0435 \u0438\u0437 \u0445\u0443\u043a\u0430 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 &#8212; \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u043d\u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u0440\u0435\u0434\u0438\u0441\u0435\u0440\u0430\u043c\u0438 \u0438 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 Mobx \u0438 \u0438\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u0440\u0435\u0434\u0443\u043a\u0441\u0430 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0437\u0433\u0430 \ud83d\ude42<\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e:<\/p>\n<p><a href=\"https:\/\/mobx.js.org\/react-integration.html\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/mobx.js.org\/react-integration.html<\/u><\/a><\/p>\n<p>\u0441\u043f\u0430\u0441\u0438\u0431\u043e<\/p>\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7dc\/d73\/3cc\/7dcd733ccd10a34d56b15721f2d122a6.png\" width=\"1200\" height=\"675\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7dc\/d73\/3cc\/7dcd733ccd10a34d56b15721f2d122a6.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/747884\/\"> https:\/\/habr.com\/ru\/articles\/747884\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h4>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Mobx?<\/h4>\n<p>Mobx\u00a0\u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0434\u0430\u044e\u0449\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f\u00a0\u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<p>Mobx \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0430\u044f \u0432\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u0432\u00a0\u0441\u0432\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Context API \u0438, \u043f\u043e\u00a0\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441\u00a0Redux, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0430\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f\u00a0\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u043e\u0440\u0430.<\/p>\n<p>Mobx \u0441\u0442\u043e\u0440\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0434\u043b\u044f\u00a0\u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u043c\u0435\u0449\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u044c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0441\u0442\u043e\u0440\u0430.<\/p>\n<h4>\u0417\u0430\u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u044b?<\/h4>\n<p>\u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u043e\u0440 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432\u00a0\u0441\u0442\u043e\u0440\u0430\u0445 \u0443\u0434\u043e\u0431\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b\u00a0\u2014 \u0431\u0443\u0434\u044c \u0442\u043e api\u2011\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438\u00a0\u043f\u0430\u0440\u0441\u0435\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445\u00a0\u2014 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u00a0\u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445, \u043d\u043e\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043f\u043e\u00a0\u0434\u0435\u0440\u0435\u0432\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u043e\u0442\u043e\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0431\u0435\u0437\u00a0\u0438 \u0441\u00a0Mobx \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043d\u0430\u00a0\u0441\u043b\u0430\u0439\u0434\u0435:<\/p>\n<figure class=\"full-width\"><\/figure>\n<h4>\u0418\u0437 \u0447\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 Mobx \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/h4>\n<p>Mobx \u0441\u0442\u043e\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437\u00a0\u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439\u00a0\u2014 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430 \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430\u00a0\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438 \u0438 \u0437\u0430\u00a0\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0442\u043e\u0440. \u0422\u0430\u043a\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f\u00a0\u0441\u0442\u043e\u0440\u0430. \u0410\u00a0\u0432\u00a0\u0444\u0430\u0439\u043b\u0435 \u0441\u00a0\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0445\u0443\u043a \u0434\u043b\u044f\u00a0\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430 \u0432\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435.<\/p>\n<p>\u0421\u0442\u043e\u0440 \u0432\u00a0\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u2011\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u043e\u00a0\u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430, \u0438 \u043f\u0440\u0438\u00a0\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u044d\u0442\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e DOM.<\/p>\n<p>\u0424\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u00a0\u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0441\u0442\u043e\u0440\u0430, \u0444\u0430\u0439\u043b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u0442, \u043d\u043e\u00a0\u0438\u0437\u00a0\u043d\u0435\u0433\u043e \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0445\u0443\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0432\u00a0\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0442\u043e\u0440.<\/p>\n<p>\u0418\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u044b\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0442\u043e\u0440\u0430, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u043e\u00a0\u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e\u00a0\u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438\u0437\u00a0\u043d\u0435\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u0442.<\/p>\n<h4>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b<\/h4>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Mobx \u0432 react-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c:<\/p>\n<pre><code class=\"bash\">npm i mobx mobx-react-lite<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0441\u0442\u043e\u0440, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u0430\u043f\u043a\u0443 stores, \u0438 \u0432 \u043d\u0435\u0439 \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u043e\u0440\u0430 &#8212; AppStore. \u0412 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 &#8212; \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0434\u043b\u044f \u043e\u0431\u044c\u0435\u043a\u0442\u0430-\u0441\u0442\u043e\u0440\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0443 index.js, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 AppStore \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443.<\/p>\n<p>\u0424\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0442\u043e\u0440\u0430, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p><strong>\/stores<\/strong><\/p>\n<p><strong>\u00a0\u00a0  \/AppStore<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0    AppStoreProvider.jsx<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0    AppStore.js<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0    index.js<\/strong><\/p>\n<h4>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0441\u0442\u043e\u0440\u0430<\/h4>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u044c\u044f\u0432\u0438\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0438 \u0441\u0442\u043e\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f test \u0438 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f toggleTest:<\/p>\n<p><strong>AppStoreProvider.jsx<\/strong><\/p>\n<pre><code class=\"javascript\">import { createContext, useContext } from 'react'; import { observer, useLocalObservable } from 'mobx-react-lite'; import { createAppStore } from '.\/AppStore';  const Context = createContext(null);  export const AppStoreProvider = observer(({ children, ...props }) => {   const store = useLocalObservable(() => createAppStore(props));   return &lt;Context.Provider value={store}>{children}&lt;\/Context.Provider>; });  export const useAppStore = () => {   const store = useContext(Context);   if (!store) throw new Error('Use App store within provider!');   return store; };<\/code><\/pre>\n<p><strong>AppStore.js<\/strong><\/p>\n<pre><code class=\"javascript\">export const createAppStore = (props) => {   return {     test: props.test || 'Hello world',     toggleTest: function () {       this.test = this.test === 'Hi!' ? 'How are you?' : 'Hi!';     },       }; };<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0441\u0442\u043e\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u043e\u0440, \u0432\u00a0\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f\u00a0\u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430.<\/p>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0433\u0434\u0435 \u0443\u0433\u043e\u0434\u043d\u043e, \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440 \u0438\u043c\u0435\u043b \u043d\u0430\u00a0\u043a\u0430\u043a\u043e\u043c \u0442\u043e \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0432\u043e\u0438\u043c \u043f\u0440\u0435\u0434\u043a\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u0412\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043b\u0443\u0447\u0448\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432\u00a0\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043d\u0430\u00a0\u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">import React, {} from 'react'; import {AppStoreProvider} from '~store\/AppStore'; \/\/ index.jsx import {MyComponent} from '.\/MyComponent';  export const App = () => {   return (     &lt;AppStoreProvider>       &lt;MyComponent \/>     &lt;\/AppStoreProvider>   ); }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f\u00a0\u0441\u0442\u043e\u0440\u0430:<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440 \u0432\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435.<\/p>\n<p>\u0414\u043b\u044f\u00a0\u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043b\u0441\u044f \u043f\u0440\u0438\u00a0\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u043e\u0440\u0430, \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u044e observer \u0438\u0437\u00a0\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 mobx\u2011react\u2011lite.<\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u043e\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0438\u0437\u00a0\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u0445\u0443\u043a\u0430 useAppStore:<\/p>\n<pre><code class=\"javascript\">import React from 'react'; import {observer} from 'mobx-react-lite'; import {useAppStore} from '~store\/AppStore'; \/\/ index.jsx  export const MyComponent = observer(() => {   const appStore = useAppStore();    return (     &lt;>       &lt;h1>{appStore.test}&lt;\/h1>       &lt;button onClick={() => appStore.toggleTest()}>Toggle&lt;\/button>     &lt;\/>   ); });<\/code><\/pre>\n<h4>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/h4>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e Mobx \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043b\u044f\u00a0\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0414\u043e\u0441\u0442\u0443\u043f \u043a\u00a0\u043d\u0435\u0431\u0443 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u00a0\u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0435\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 useState \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0437\u0430\u00a0\u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0422\u0430\u043a\u0436\u0435 \u0432\u00a0\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0414\u043b\u044f\u00a0\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u00a0\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435: <\/p>\n<pre><code class=\"javascript\">const localStore = useLocalStore();<\/code><\/pre>\n<p>\u0418 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0441\u0430\u043c\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0444\u0430\u0439\u043b\u0435:<\/p>\n<pre><code class=\"javascript\">import { useLocalObservable } from 'mobx-react-lite';  const createLocalStore = (props) => {   return {     hello: props.hello || 'Hello world',     toggleHello: function () {       this.hello = this.hello !== 'Hi!' ? 'How are you?' : 'Hi!';     },       }; };  export const useLocalStore = (props = {}) => {   return useLocalObservable(() => createLocalStore(props)); };<\/code><\/pre>\n<h4>\u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433<\/h4>\n<p>\u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044c\u044f\u0432\u0438\u0442\u044c mobx \u0441\u0442\u043e\u0440 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435.<\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e, \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c Mobx \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0442\u044e \u0441 Redux \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 &#8212; \u043a\u0430\u043a \u0432 \u043e\u0431\u044c\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0442\u0430\u043a \u0438 \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0438 \u0441\u0442\u043e\u0440\u043e\u0432. \u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 Mobx \u043f\u0440\u043e\u0441\u0442\u0430\u044f &#8212; \u043e\u0431\u044c\u044f\u0432\u043b\u044f\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0441\u0442\u043e\u0440\u0435 \u0438 \u0434\u043e\u0441\u0442\u0430\u0435\u0442\u0435 \u0435\u0435 \u0438\u0437 \u0445\u0443\u043a\u0430 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 &#8212; \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u043d\u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u0440\u0435\u0434\u0438\u0441\u0435\u0440\u0430\u043c\u0438 \u0438 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 Mobx \u0438 \u0438\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u0440\u0435\u0434\u0443\u043a\u0441\u0430 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0437\u0433\u0430 \ud83d\ude42<\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e:<\/p>\n<p><a href=\"https:\/\/mobx.js.org\/react-integration.html\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/mobx.js.org\/react-integration.html<\/u><\/a><\/p>\n<p>\u0441\u043f\u0430\u0441\u0438\u0431\u043e<\/p>\n<figure class=\"float full-width\"><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/747884\/\"> https:\/\/habr.com\/ru\/articles\/747884\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-350235","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350235","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=350235"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350235\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}