{"id":370314,"date":"2024-05-21T04:22:21","date_gmt":"2024-05-21T04:22:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=370314"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T04:22:21","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=370314","title":{"rendered":"<span>Zustand.js: \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439, \u043d\u0435\u0432\u0435\u0441\u043e\u043c\u044b\u0439, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u0433\u0438\u0431\u043a\u0438\u0439 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<p>\u0421\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 \u0447\u0430\u0441\u0442\u0438 <a href=\"https:\/\/budarin.github.io\/zustand-presentation\/?full#cover\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u043b\u0430\u0434\u0430<\/a>.<\/p>\n<p>\u0418 \u0442\u0430\u043a \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f:<\/p>\n<p> Zustand &#8212; \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u0445 Flux \u0438 immutable state. \u0418\u043c\u0435\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 API, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0445\u0443\u043a\u0430\u0445, \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u043d\u0435 \u043d\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0436\u0435\u0441\u0442\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 Zombie children \u0438 context loss \u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 React concurrency mode.<\/p>\n<p>Zustand \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u043b\u044e\u0431\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u0432 \u043a\u043e\u0434\u0435 React<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u043c JavaScript<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0431\u0430\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 publish\/subscribe \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0445\u0443\u043a\u0430 \u0434\u043b\u044f React.<\/p>\n<h3>\u041b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439<\/h3>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/92e\/f48\/9c8\/92ef489c8022132582a597fee851a19c.png\" alt=\"Zustand bundlephobia\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/92e\/f48\/9c8\/92ef489c8022132582a597fee851a19c.png\"\/><\/p>\n<div><figcaption>Zustand bundlephobia<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0443\u0442 \u0434\u0430\u0436\u0435 \u043d\u0435\u0447\u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &#8212; 693 \u0431\u0430\u0439\u0442\u0430! \u041d\u0435 \u0437\u043d\u0430\u044e \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0435\u0449\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0435\u043c \u044d\u0442\u0430.<\/p>\n<h3>\u041f\u0440\u043e\u0441\u0442\u043e\u0439<\/h3>\n<p>Zustand \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430:<\/p>\n<pre><code class=\"typescript\">const storeHook = create((set, get) => { ... store config ... }); <\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435:<\/p>\n<pre><code class=\"typescript\">import { create } from 'zustand';  export const useCounterStore = create((set) => ({     count: 0,      increment: () => set((state) => ({ count: state.count + 1 })),     decrement: () => set((state) => ({ count: state.count - 1 })), })); <\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c React \u0445\u0443\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445.<\/p>\n<p>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f React \u0442\u0430\u043a \u0438 \u0432 javascript \u0432\u043d\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 React (\u043d\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u0435\u0439\u0442-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043d\u0430 \u0442\u0430\u043a\u043e\u0435).<\/p>\n<p>Zustand \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c &#8212; \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 React.<\/p>\n<p>\u0412 Zustand \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0448\u0435\u0439 \u0434\u0443\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<pre><code class=\"typescript\">import { create } from 'zustand';  export const useCatsStore = create((set) => ({     count: 0,      increment: () => set((state) => ({ count: state.count + 1 })),     decrement: () => set((state) => ({ count: state.count - 1 })), }));  export const useDogsStore = create((set) => ({     count: 0,      increment: () => set((state) => ({ count: state.count + 1 })),     decrement: () => set((state) => ({ count: state.count - 1 })), })); <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0445\u0443\u043a \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/p>\n<pre><code class=\"typescript\">storeHook: (selector) => selectedState; <\/code><\/pre>\n<p>\u0433\u0434\u0435 selector &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0435\u0439 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/p>\n<pre><code class=\"typescript\">const stateData = storeHook((state) => {     \/\/ \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445  \u0438\u0437  state     ...     return selectedState; }); <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 React \u0445\u0443\u043a, \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445<\/p>\n<pre><code class=\"typescript\">function Counter() {     const { count, increment } = useCounterStore((state) => state);      return &lt;button onClick={increment}>{count}&lt;\/button>; } <\/code><\/pre>\n<h3>\u0423\u0434\u043e\u0431\u043d\u044b\u0439<\/h3>\n<p>\u0425\u0443\u043a \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (\u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 pub\/sub) :<\/p>\n<pre><code class=\"typescript\">{     getState: () => state,     setState: (newState) => void,     subscribe: (callback) => void,     ... } <\/code><\/pre>\n<p>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u0445<\/p>\n<pre><code class=\"typescript\">function Counter() {     const count = useCounterStore((state) => state.counter);      function onClick() {         const state = useCounterStore.getState();          useCounterStore.setState({             count: state.count + 3;         });     }      return &lt;button onClick={onClick}>{count}&lt;\/button>; } <\/code><\/pre>\n<p>\u0412 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b:<\/p>\n<pre><code class=\"typescript\">const useCounterStore = create((set) => ({     count: 0,      increment: async () => {         const resp = await fetch('https:\/\/my-bank\/api\/getBalance');         const { balance } = await resp.json();          set((state) => {             return { count: state.count + balance };         });     }, })); <\/code><\/pre>\n<p>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435<\/p>\n<pre><code class=\"typescript\">function Counter() {     const count = useCounterStore((state) => state.counter);      function onClick() {         const resp = await fetch('https:\/\/my-bank\/api\/getBalance');         const { balance } = await resp.json();          useCounterStore.setState({             count: count + balance,         });     }      return &lt;button onClick={onClick}>{count}&lt;\/button>; } <\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0432\u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/p>\n<pre><code class=\"typescript\">const useCounterStore = create(() => ({     count: 0, }));  const increment = () => {     const state = useCounterStore.getState();     useCounterStore.setState({ count: state.count + 1 }); }; <\/code><\/pre>\n<p>\u0412 Zustand \u043a\u0430\u043a \u0438 \u0432 Redux \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 middleware!<br \/> \u0421 \u043d\u0438\u043c \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0435 middlewares:<\/p>\n<ul>\n<li>\n<p><strong>persist<\/strong>: \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f\/\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\/\u0438\u0437 localStorage<\/p>\n<\/li>\n<li>\n<p><strong>immer<\/strong>: \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><strong>devtools<\/strong>: \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c redux devtools \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439<\/h3>\n<p>\u0410 \u0447\u0442\u043e\u0436\u0435 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c ?<\/p>\n<p> \u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u043d\u0430\u0438\u0432\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0445\u0443\u043a\u0430 Zustand, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0443<\/p>\n<pre><code class=\"typescript\">function useStore(selector) {     const [prevState, setPrevState] = useState(store.getState(selector));      useEffect(() => {         const unsubscribe = store.subscribe((newState) => {             const currentState = selector(newState);              if (currentState !== prevState) {                 setPrevState(currentState);             }         });          return () => {             unsubscribe();         };     }, [selector]);      return prevState; } <\/code><\/pre>\n<p>\u0412 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0443\u043a\u0430 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0445\u0443\u043a\u0430.<br \/> \u0414\u0430\u043b\u0435\u0435 \u0432 \u044d\u0444\u0444\u0435\u043a\u0442\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f pusb\/sub \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439, \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0445\u0443\u043a\u0430. \u0415\u0441\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0435 \u0440\u0430\u0432\u043d\u044b ( \u0430 \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435) &#8212; \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0445\u0443\u043a\u0430.<\/p>\n<p>\u041a\u0443\u0434\u0430 \u0443\u0436 \u043f\u0440\u043e\u0449\u0435 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 !?<br \/> \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u043d\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 React ( \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 pub\/sub ) \u0434\u0430\u043d\u043d\u044b\u0439 \u0445\u0443\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438 \u0432 Concurrency mode \u0432 React 18+, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u0443\u043a\u0430 Zustand \u0431\u0430\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u043e\u0432\u043e\u043c \u0445\u0443\u043a\u0435 React \u0434\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0434\u0435\u0440\u0435\u0432\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<pre><code class=\"typescript\">function useStore(store, selector, equalityFn) {     return useSyncExternalStoreWithSelector(         store.subscribe,         store.getState,         store.getServerState || store.getInitialState,         selector,         equalityFn,     ); } <\/code><\/pre>\n<p>\u0412 Concurrency mode \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 React \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 DOM \u0438 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 &#8212; \u044d\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u043d\u0438 \u043e\u0434\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d\u043e.<br \/> \u041a\u043e\u043c\u0430\u043d\u0434\u0430 React \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0434 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0433\u0440\u0443\u0431\u043e\u0433\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b React \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430.<\/p>\n<h3>\u041c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0442 \u0438\u0437 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0443\u043a\u0430 &#8212; \u0445\u0443\u043a <code>useEffect<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0430\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0438\u043c!<\/p>\n<p>\u0418\u0445 \u0432\u0441\u0435\u0433\u043e 3 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<ol>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 &#8212; \u0432\u044b\u043d\u0435\u0441\u0438\u0442\u0435 \u0435\u0433\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0438 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"typescript\">const countSelector = (state) => state.count;  function Counter() {     const count = useCounterStore(countSelector);     return &lt;div>{count}&lt;\/div>; } <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b &#8212; \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 useCallback &#8212; \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"typescript\">function TodoItem({ id }) {     const selectTodo = useCallback((state) => state.todos[id], [id]);     const todo = useTodoStore(selectTodo);      return (         &lt;li>             &lt;span>{todo.id}&lt;\/span>             &lt;span>{todo.text}&lt;\/span>         &lt;\/li>     ); } <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 &#8212; \u043e\u0431\u0435\u0440\u043d\u0438\u0442\u0435 \u0432\u044b\u0437\u043e\u0432 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430 \u0432 useShallow &#8212; \u0435\u0441\u043b\u0438 \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c &#8212; \u0445\u0443\u043a useShallow \u0432\u044b\u0434\u0430\u0441\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"typescript\">import { useShallow } from 'zustand\/react\/shallow';  const selector = (state) => Object.keys(state);  function StoreInfo() {     const entityNames = useSomeStore(useShallow(selector));     return (         &lt;div>             &lt;div>{entityNames.join(', ')}&lt;\/div>         &lt;\/div>     ); } <\/code><\/pre>\n<p>\u0435\u0441\u043b\u0438 \u0436\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 &#8212; \u043e\u0431\u0435\u0440\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 useCallback \u0438 \u0437\u0430\u0442\u0435\u043c \u0432 useShallow<\/p>\n<pre><code class=\"typescript\">import { useShallow } from 'zustand\/react\/shallow';  function TodoItemFieldNames({ id }) {     const selectFieldNames = useCallback((state) => Object.keys(state.todos[id]), [id]);     const fieldNames = useTodoStore(useShallow(selectFieldNames));      return (         &lt;li>             &lt;span>{fieldNames.join(', ')}&lt;\/span>         &lt;\/li>     ); } <\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d &#171;\u0442\u0443\u0440\u0431\u043e&#187; \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u0438\u043d\u0443\u044f \u0446\u0438\u043a\u043b \u0440\u0435\u043d\u0434\u0435\u0440\u0430 React &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 DOM \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e<\/p>\n<pre><code class=\"typescript\">function Counter() {     const counterRef = useRef(null);     const countRef = useRef(useCounterStore.getState().count);      useEffect(         () =>             useCounterStore.subscribe((state) => {                 countRef.current = state.count;                 counterRef.current.textContent = countRef.current;             }),         [],     );      return (         &lt;div>             &lt;span>Count: &lt;\/span>             &lt;span ref={counterRef}>{countRef.current}&lt;\/span>         &lt;\/div>     ); } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <code>countRef<\/code> \u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0430\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0435\u0433\u043e. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>countRef<\/code> \u0438 \u0437\u0430\u0442\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 DOM \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>counterRef<\/code>.<br \/> \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0437\u0430\u0442\u0435\u043c React \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 &#8212; \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <code>countRef<\/code>.<\/p>\n<h3>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438<\/h3>\n<ol>\n<li>\n<p><strong>\u0412\u0441\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u0440\u0436\u0438\u0442\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>Zustand \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430\u0445 \u0438\u043d\u0430\u0447\u0435 \u0432\u044b \u0432\u0435\u0440\u043d\u0435\u0442\u0435\u0441\u044c \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0435 &#8212; \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 model hell \u0438\u0437 MVC \u0438 FLUX (\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0445\u0430\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043d\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0440\u0430\u0437\u043d\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0435\u0434\u0443\u0449\u0438\u0445 \u043a \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u0438\u043c\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0430\u043c\u0438 \u043f\u043e \u0432\u0435\u0447\u0435\u0440\u0430\u043c \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u0439 &#8212; \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432 \u0434\u043e\u043a\u043b\u0430\u0434\u0435).<\/p>\n<p>\u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u043b\u043e\u0434\u043e\u0435 \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0445 \u0441 MVC \u0438 FLUX \u0438 \u043d\u0435 \u0438\u0437\u0443\u0447\u0430\u0432\u0448\u0438\u0445 \u0442\u0435\u043e\u0440\u0438\u044e, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u0442\u043e\u043c\u043d\u044b\u0435, \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u044f\u0440\u043d\u044b\u0435, \u043f\u0440\u043e\u0442\u043e\u043d\u043d\u044b\u0435, \u043d\u0435\u0439\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u0438 \u0432\u0441\u044f\u043a\u0438\u0435 \u043a\u0432\u0430\u0440\u043a\u043e\u0432\u044b\u0435 \u0441\u0442\u0435\u0439\u0442-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b, \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u043d\u0430 \u0433\u0440\u0430\u0431\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0434\u0443\u0441\u0442\u0440\u0438\u044f \u043f\u0440\u043e\u0448\u043b\u0430 \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434.<\/p>\n<p>\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u043b\u0436\u043d\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<br \/> \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<ol start=\"2\">\n<li>\n<p><strong>\u041c\u0435\u0442\u043e\u0434\u044b \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u0435 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e \u0447\u0442\u043e Zustand \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043f\u0440\u044f\u043c\u043e \u0432 \u043d\u0435\u043c \u0441\u0430\u043c\u043e\u043c, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e &#8212; \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043d\u043e\u0433\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438\u043b\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0435, \u0430 \u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u044a\u0435\u043c\u043d\u044b\u0435 &#8212; \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c, \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u043c \u0438 \u043f\u043b\u043e\u0445\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u043c.<\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u0434\u0430\u0435\u0442 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0431\u043e\u043d\u0443\u0441 &#8212; \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043c\u044b \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u043b\u0435\u0433\u0447\u0435 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0432 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043e\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430.<\/p>\n<ol start=\"3\">\n<li>\n<p><strong>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432!<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>\u042f \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0438 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u043b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u043f\u043e\u0434\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0447\u0430\u0441\u0442\u044c \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c, \u044f\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u044d\u0442\u0443 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0443!<br \/> \u041d\u0435\u0442 \u043d\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044e \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0438 \u0438\u0445 \u043d\u0435\u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438!<br \/> \u041f\u043e\u0434\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0432\u0438\u0434\u0435\u043b \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u043e\u0439 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0435 Json \u0445\u0440\u0430\u043d\u0438\u043b\u043a\u0438! \u042d\u0442\u043e \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u043a\u0438 json.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0435\u0441\u0442\u044c \u0442\u043e \u044f\u0434\u0440\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e &#8212; \u0442\u0430\u043a\u0438\u043c \u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (\u044f\u0434\u0440\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f) &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f Json \u0445\u0440\u0430\u043d\u0438\u043b\u043a\u0430 &#8212; \u0442\u043e 99.99% \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0445\u043e\u0440\u0430\u0434\u0438\u0442\u044c \u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0431\u0430\u0433\u043e\u0432. \u0422\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u0434 \u043f\u043e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0430\u0437\u0430\u043d \u0438 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u0447\u0430\u0441\u0442\u044f\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0410 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0445 \u043d\u0435\u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u0431\u0430\u0433\u0430\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043b\u0438\u043a\u0432\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0431\u0430\u0433\u043e\u0432 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c\u0441\u044f \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0442\u043e\u0434\u044b \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0435\u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0432\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">import { create } from 'zustand';  \/\/ \u043d\u0438\u043a\u043e\u0434\u0430 \u043d\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0430\u043c \u0445\u0443\u043a \u0441 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443! const useCounterStore = create(() => ({     count: 0, }));  \/\/ \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0445\u0443\u043a - \u043d\u0435 \u0434\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 export const useCounter = () => useCounterStore((state) => state.count);  \/\/ \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 export const increment = () => {     const state = useCounterStore.getState();     useCounterStore.setState({ count: state.count + 1 }); }; <\/code><\/pre>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0435 \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 &#8212; \u043d\u0438 \u043e\u0434\u0438\u043d \u0434\u0436\u0443\u043d \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u0435\u0442 \u0432\u0430\u0448\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u0443\u0442\u0435\u043c \u043c\u0443\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 (\u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e &#8212; \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043d\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c &#8212; \u0432\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435).<\/p>\n<p>\u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0442\u0435\u0439\u0442-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p><strong>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/strong>:<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e Zustand \u0438 \u043e\u0433\u043b\u044f\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 10 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0438\u043f\u0430 <code>pub\/sub<\/code>, \u0438 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u0437\u043e\u043e\u043f\u0430\u0440\u043a \u044d\u0442\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u043e\u0434\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433 \u0445\u0443\u043a\u0430 (\u0447\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043d\u0430 \u0441\u0442\u0430\u0440\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445) \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043d\u0434\u0443\u0441\u0442\u0440\u0438\u044f \u0441\u0432\u0435\u0440\u043d\u0443\u043b\u0430 \u043d\u0435 \u0442\u0443\u0434\u0430 \u0438 \u043c\u044b \u043f\u043e\u0448\u043b\u0438 \u043d\u0435 \u0437\u0430 \u0442\u0435\u043c\u0438 \u0438 \u043b\u0438\u0448\u044c \u0441\u043f\u0443\u0441\u0442\u044f 10 \u043b\u0435\u0442 \u043c\u044b \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0432\u044b\u0448\u043b\u0438 \u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u0440\u043e\u0433\u0443: \u043e\u0434\u043d\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 (\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 -> \u0440\u0435\u0430\u043a\u0446\u0438\u044f \u044e\u0437\u0435\u0440\u0430 -> \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 -> \u0445\u0443\u043a \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439) \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<p> \u041f\u043e \u043f\u0443\u0442\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0441\u0442\u0438 FLUX, \u0438 \u0437\u0430\u0442\u0435\u043c \u0443\u0439\u0442\u0438 \u0435\u0449\u0435 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 Redux, \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u043e\u0449\u0443\u043f\u044c \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0442\u044b\u0441\u044f\u0447 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0441\u0442\u0435\u0439\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432.<\/p>\n<p>\u041d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0442\u043e, \u0447\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f!<\/p>\n<p>Zustand &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0435\u0447\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430!<\/p>\n<ul>\n<li>\n<p>\u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u0433\u043d\u0438\u0442\u0438\u0432\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439<\/p>\n<\/li>\n<li>\n<p>\u043b\u0435\u0433\u043a\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439<\/p>\n<\/li>\n<li>\n<p>\u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0439<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u0434<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0442\u0438\u043f\u0430 Zombie children \u0438 context loss<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 React concurrency mode<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Zustand \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0435\u0433\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0432\u0435\u0442 \u0438 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043c\u043e\u0446\u0438\u0438 \u043e\u0442 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0438\u0442\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Zustand \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 &#8212; \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u044b \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u043e\u0439 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c.<\/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\/798923\/\"> https:\/\/habr.com\/ru\/articles\/798923\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\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 \u0447\u0430\u0441\u0442\u0438 <a href=\"https:\/\/budarin.github.io\/zustand-presentation\/?full#cover\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u043b\u0430\u0434\u0430<\/a>.<\/p>\n<p>\u0418 \u0442\u0430\u043a \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f:<\/p>\n<p> Zustand &#8212; \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u0445 Flux \u0438 immutable state. \u0418\u043c\u0435\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 API, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0445\u0443\u043a\u0430\u0445, \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u043d\u0435 \u043d\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0436\u0435\u0441\u0442\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 Zombie children \u0438 context loss \u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 React concurrency mode.<\/p>\n<p>Zustand \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u043b\u044e\u0431\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u0432 \u043a\u043e\u0434\u0435 React<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u043c JavaScript<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0431\u0430\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 publish\/subscribe \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0445\u0443\u043a\u0430 \u0434\u043b\u044f React.<\/p>\n<h3>\u041b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439<\/h3>\n<figure class=\"\">\n<div><figcaption>Zustand bundlephobia<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0443\u0442 \u0434\u0430\u0436\u0435 \u043d\u0435\u0447\u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &#8212; 693 \u0431\u0430\u0439\u0442\u0430! \u041d\u0435 \u0437\u043d\u0430\u044e \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0435\u0449\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0435\u043c \u044d\u0442\u0430.<\/p>\n<h3>\u041f\u0440\u043e\u0441\u0442\u043e\u0439<\/h3>\n<p>Zustand \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430:<\/p>\n<pre><code class=\"typescript\">const storeHook = create((set, get) => { ... store config ... }); <\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435:<\/p>\n<pre><code class=\"typescript\">import { create } from 'zustand';  export const useCounterStore = create((set) => ({     count: 0,      increment: () => set((state) => ({ count: state.count + 1 })),     decrement: () => set((state) => ({ count: state.count - 1 })), })); <\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c React \u0445\u0443\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445.<\/p>\n<p>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f React \u0442\u0430\u043a \u0438 \u0432 javascript \u0432\u043d\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 React (\u043d\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u0435\u0439\u0442-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043d\u0430 \u0442\u0430\u043a\u043e\u0435).<\/p>\n<p>Zustand \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c &#8212; \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 React.<\/p>\n<p>\u0412 Zustand \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0448\u0435\u0439 \u0434\u0443\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<pre><code class=\"typescript\">import { create } from 'zustand';  export const useCatsStore = create((set) => ({     count: 0,      increment: () => set((state) => ({ count: state.count + 1 })),     decrement: () => set((state) => ({ count: state.count - 1 })), }));  export const useDogsStore = create((set) => ({     count: 0,      increment: () => set((state) => ({ count: state.count + 1 })),     decrement: () => set((state) => ({ count: state.count - 1 })), })); <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0445\u0443\u043a \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/p>\n<pre><code class=\"typescript\">storeHook: (selector) => selectedState; <\/code><\/pre>\n<p>\u0433\u0434\u0435 selector &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0435\u0439 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/p>\n<pre><code class=\"typescript\">const stateData = storeHook((state) => {     \/\/ \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445  \u0438\u0437  state     ...     return selectedState; }); <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 React \u0445\u0443\u043a, \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445<\/p>\n<pre><code class=\"typescript\">function Counter() {     const { count, increment } = useCounterStore((state) => state);      return &lt;button onClick={increment}>{count}&lt;\/button>; } <\/code><\/pre>\n<h3>\u0423\u0434\u043e\u0431\u043d\u044b\u0439<\/h3>\n<p>\u0425\u0443\u043a \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (\u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 pub\/sub) :<\/p>\n<pre><code class=\"typescript\">{     getState: () => state,     setState: (newState) => void,     subscribe: (callback) => void,     ... } <\/code><\/pre>\n<p>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u0445<\/p>\n<pre><code class=\"typescript\">function Counter() {     const count = useCounterStore((state) => state.counter);      function onClick() {         const state = useCounterStore.getState();          useCounterStore.setState({             count: state.count + 3;         });     }      return &lt;button onClick={onClick}>{count}&lt;\/button>; } <\/code><\/pre>\n<p>\u0412 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b:<\/p>\n<pre><code class=\"typescript\">const useCounterStore = create((set) => ({     count: 0,      increment: async () => {         const resp = await fetch('https:\/\/my-bank\/api\/getBalance');         const { balance } = await resp.json();          set((state) => {             return { count: state.count + balance };         });     }, })); <\/code><\/pre>\n<p>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435<\/p>\n<pre><code class=\"typescript\">function Counter() {     const count = useCounterStore((state) => state.counter);      function onClick() {         const resp = await fetch('https:\/\/my-bank\/api\/getBalance');         const { balance } = await resp.json();          useCounterStore.setState({             count: count + balance,         });     }      return &lt;button onClick={onClick}>{count}&lt;\/button>; } <\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0432\u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/p>\n<pre><code class=\"typescript\">const useCounterStore = create(() => ({     count: 0, }));  const increment = () => {     const state = useCounterStore.getState();     useCounterStore.setState({ count: state.count + 1 }); }; <\/code><\/pre>\n<p>\u0412 Zustand \u043a\u0430\u043a \u0438 \u0432 Redux \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 middleware!<br \/> \u0421 \u043d\u0438\u043c \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0435 middlewares:<\/p>\n<ul>\n<li>\n<p><strong>persist<\/strong>: \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f\/\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\/\u0438\u0437 localStorage<\/p>\n<\/li>\n<li>\n<p><strong>immer<\/strong>: \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><strong>devtools<\/strong>: \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c redux devtools \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439<\/h3>\n<p>\u0410 \u0447\u0442\u043e\u0436\u0435 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c ?<\/p>\n<p> \u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u043d\u0430\u0438\u0432\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0445\u0443\u043a\u0430 Zustand, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0443<\/p>\n<pre><code class=\"typescript\">function useStore(selector) {     const [prevState, setPrevState] = useState(store.getState(selector));      useEffect(() => {         const unsubscribe = store.subscribe((newState) => {             const currentState = selector(newState);              if (currentState !== prevState) {                 setPrevState(currentState);             }         });          return () => {             unsubscribe();         };     }, [selector]);      return prevState; } <\/code><\/pre>\n<p>\u0412 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0443\u043a\u0430 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0445\u0443\u043a\u0430.<br \/> \u0414\u0430\u043b\u0435\u0435 \u0432 \u044d\u0444\u0444\u0435\u043a\u0442\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f pusb\/sub \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439, \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0445\u0443\u043a\u0430. \u0415\u0441\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0435 \u0440\u0430\u0432\u043d\u044b ( \u0430 \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435) &#8212; \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0445\u0443\u043a\u0430.<\/p>\n<p>\u041a\u0443\u0434\u0430 \u0443\u0436 \u043f\u0440\u043e\u0449\u0435 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 !?<br \/> \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u043d\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 React ( \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 pub\/sub ) \u0434\u0430\u043d\u043d\u044b\u0439 \u0445\u0443\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430\u043c\u0438 \u0432 Concurrency mode \u0432 React 18+, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u0443\u043a\u0430 Zustand \u0431\u0430\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u043e\u0432\u043e\u043c \u0445\u0443\u043a\u0435 React \u0434\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0434\u0435\u0440\u0435\u0432\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<pre><code class=\"typescript\">function useStore(store, selector, equalityFn) {     return useSyncExternalStoreWithSelector(         store.subscribe,         store.getState,         store.getServerState || store.getInitialState,         selector,         equalityFn,     ); } <\/code><\/pre>\n<p>\u0412 Concurrency mode \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 React \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 DOM \u0438 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 &#8212; \u044d\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u043d\u0438 \u043e\u0434\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d\u043e.<br \/> \u041a\u043e\u043c\u0430\u043d\u0434\u0430 React \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0434 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0433\u0440\u0443\u0431\u043e\u0433\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b React \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430.<\/p>\n<h3>\u041c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0442 \u0438\u0437 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0443\u043a\u0430 &#8212; \u0445\u0443\u043a <code>useEffect<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0430\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0438\u043c!<\/p>\n<p>\u0418\u0445 \u0432\u0441\u0435\u0433\u043e 3 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<ol>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 &#8212; \u0432\u044b\u043d\u0435\u0441\u0438\u0442\u0435 \u0435\u0433\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0438 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"typescript\">const countSelector = (state) => state.count;  function Counter() {     const count = useCounterStore(countSelector);     return &lt;div>{count}&lt;\/div>; } <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b &#8212; \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 useCallback &#8212; \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"typescript\">function TodoItem({ id }) {     const selectTodo = useCallback((state) => state.todos[id], [id]);     const todo = useTodoStore(selectTodo);      return (         &lt;li>             &lt;span>{todo.id}&lt;\/span>             &lt;span>{todo.text}&lt;\/span>         &lt;\/li>     ); } <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0435\u0441\u043b\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 &#8212; \u043e\u0431\u0435\u0440\u043d\u0438\u0442\u0435 \u0432\u044b\u0437\u043e\u0432 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430 \u0432 useShallow &#8212; \u0435\u0441\u043b\u0438 \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c &#8212; \u0445\u0443\u043a useShallow \u0432\u044b\u0434\u0430\u0441\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"typescript\">import { useShallow } from 'zustand\/react\/shallow';  const selector = (state) => Object.keys(state);  function StoreInfo() {     const entityNames = useSomeStore(useShallow(selector));     return (         &lt;div>             &lt;div>{entityNames.join(', ')}&lt;\/div>         &lt;\/div>     ); } <\/code><\/pre>\n<p>\u0435\u0441\u043b\u0438 \u0436\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 &#8212; \u043e\u0431\u0435\u0440\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 useCallback \u0438 \u0437\u0430\u0442\u0435\u043c \u0432 useShallow<\/p>\n<pre><code class=\"typescript\">import { useShallow } from 'zustand\/react\/shallow';  function TodoItemFieldNames({ id }) {     const selectFieldNames = useCallback((state) => Object.keys(state.todos[id]), [id]);     const fieldNames = useTodoStore(useShallow(selectFieldNames));      return (         &lt;li>             &lt;span>{fieldNames.join(', ')}&lt;\/span>         &lt;\/li>     ); } <\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d &#171;\u0442\u0443\u0440\u0431\u043e&#187; \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u0438\u043d\u0443\u044f \u0446\u0438\u043a\u043b \u0440\u0435\u043d\u0434\u0435\u0440\u0430 React &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 DOM \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e<\/p>\n<pre><code class=\"typescript\">function Counter() {     const counterRef = useRef(null);     const countRef = useRef(useCounterStore.getState().count);      useEffect(         () =>             useCounterStore.subscribe((state) => {                 countRef.current = state.count;                 counterRef.current.textContent = countRef.current;             }),         [],     );      return (         &lt;div>             &lt;span>Count: &lt;\/span>             &lt;span ref={counterRef}>{countRef.current}&lt;\/span>         &lt;\/div>     ); } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <code>countRef<\/code> \u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0430\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0435\u0433\u043e. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>countRef<\/code> \u0438 \u0437\u0430\u0442\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 DOM \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>counterRef<\/code>.<br \/> \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0437\u0430\u0442\u0435\u043c React \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 &#8212; \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <code>countRef<\/code>.<\/p>\n<h3>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438<\/h3>\n<ol>\n<li>\n<p><strong>\u0412\u0441\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u0440\u0436\u0438\u0442\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>Zustand \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-370314","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/370314","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=370314"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/370314\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=370314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=370314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=370314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}