{"id":201,"date":"2026-07-10T09:56:25","date_gmt":"2026-07-10T01:56:25","guid":{"rendered":"https:\/\/yykcj.com\/?p=201"},"modified":"2026-07-10T09:56:25","modified_gmt":"2026-07-10T01:56:25","slug":"react-%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86%e7%bb%88%e6%9e%81%e6%8c%87%e5%8d%97%ef%bc%9azustand-vs-jotai-vs-redux-%e5%ae%9e%e6%88%98%e5%af%b9%e6%af%94","status":"publish","type":"post","link":"https:\/\/yykcj.com\/?p=201","title":{"rendered":"React \u72b6\u6001\u7ba1\u7406\u7ec8\u6781\u6307\u5357\uff1aZustand vs Jotai vs Redux \u5b9e\u6218\u5bf9\u6bd4"},"content":{"rendered":"<h2>\u524d\u8a00<\/h2>\n<p>React \u72b6\u6001\u7ba1\u7406\u4e00\u76f4\u662f\u524d\u7aef\u5f00\u53d1\u8005\u7ed5\u4e0d\u5f00\u7684\u8bdd\u9898\u3002\u4ece\u65e9\u671f\u7684 Redux \u4e00\u7edf\u6c5f\u6e56\uff0c\u5230\u5982\u4eca Zustand\u3001Jotai \u7b49\u8f7b\u91cf\u65b9\u6848\u5d1b\u8d77\uff0c\u5f00\u53d1\u8005\u9762\u4e34\u7684\u9009\u62e9\u8d8a\u6765\u8d8a\u591a\u3002\u4f46\u9009\u62e9\u591a\u4e86\uff0c\u53cd\u800c\u5bb9\u6613\u9677\u5165\u300c\u9009\u62e9\u56f0\u96be\u75c7\u300d\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5e26\u4f60\u4eb2\u624b\u5b9e\u73b0\u4e00\u4e2a\u7535\u5546\u8d2d\u7269\u8f66\u529f\u80fd\uff0c\u5206\u522b\u7528 Zustand\u3001Jotai \u548c Redux \u4e09\u79cd\u65b9\u6848\u5b8c\u6210\uff0c\u5e76\u5bf9\u6bd4\u5b83\u4eec\u7684\u4ee3\u7801\u91cf\u3001\u6027\u80fd\u3001\u53ef\u7ef4\u62a4\u6027\u53ca\u5b66\u4e60\u66f2\u7ebf\u3002\u8bfb\u5b8c\u672c\u6587\uff0c\u4f60\u5c06\u80fd\u6839\u636e\u9879\u76ee\u9700\u6c42\u505a\u51fa\u6700\u5408\u9002\u7684\u9009\u578b\u3002<\/p>\n<h2>\u9879\u76ee\u51c6\u5907<\/h2>\n<p>\u6211\u4eec\u5148\u521b\u5efa\u4e00\u4e2a React \u9879\u76ee\uff08\u4f7f\u7528 Vite + TypeScript\uff09\uff1a<\/p>\n<pre><code class=\"language-bash\">\nnpm create vite@latest state-compare -- --template react-ts\ncd state-compare\nnpm install\n<\/code><\/pre>\n<p>\u7136\u540e\u5b89\u88c5\u4e09\u4e2a\u72b6\u6001\u7ba1\u7406\u5e93\uff1a<\/p>\n<pre><code class=\"language-bash\">\nnpm install zustand jotai @reduxjs\/toolkit react-redux\n<\/code><\/pre>\n<h2>\u573a\u666f\uff1a\u8d2d\u7269\u8f66<\/h2>\n<p>\u6211\u4eec\u9700\u8981\u5b9e\u73b0\u7684\u529f\u80fd\uff1a<\/p>\n<ul>\n<li>\u5546\u54c1\u5217\u8868\uff08\u4ece API \u83b7\u53d6\uff09<\/li>\n<li>\u6dfb\u52a0\u5546\u54c1\u5230\u8d2d\u7269\u8f66<\/li>\n<li>\u8d2d\u7269\u8f66\u6570\u91cf\u52a0\u51cf<\/li>\n<li>\u5220\u9664\u5546\u54c1<\/li>\n<li>\u8ba1\u7b97\u603b\u4ef7<\/li>\n<\/ul>\n<p>\u6211\u4eec\u5c06\u5728 <code>src\/App.tsx<\/code> \u4e2d\u7edf\u4e00\u6e32\u67d3\uff0c\u4f46\u72b6\u6001\u7ba1\u7406\u903b\u8f91\u5206\u522b\u653e\u5728\u4e0d\u540c\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n<h2>\u65b9\u6848\u4e00\uff1aZustand<\/h2>\n<p>Zustand \u662f\u4e00\u4e2a\u6781\u7b80\u7684\u72b6\u6001\u7ba1\u7406\u5e93\uff0c\u6838\u5fc3\u662f\u4e00\u4e2a hook \u5f0f\u7684 store\u3002<\/p>\n<h3>1. \u521b\u5efa Store<\/h3>\n<p>\u521b\u5efa <code>src\/zustand\/store.ts<\/code>\uff1a<\/p>\n<pre><code class=\"language-typescript\">\nimport { create } from &#x27;zustand&#x27;;\nimport { persist } from &#x27;zustand\/middleware&#x27;;\n\ninterface CartItem {\n  id: number;\n  name: string;\n  price: number;\n  quantity: number;\n}\n\ninterface CartState {\n  items: CartItem[];\n  addItem: (item: Omit&lt;CartItem, &#x27;quantity&#x27;&gt;) =&gt; void;\n  removeItem: (id: number) =&gt; void;\n  updateQuantity: (id: number, quantity: number) =&gt; void;\n  clearCart: () =&gt; void;\n  total: () =&gt; number;\n}\n\nexport const useCartStore = create&lt;CartState&gt;()(\n  persist(\n    (set, get) =&gt; ({\n      items: [],\n      addItem: (item) =&gt; {\n        const items = get().items;\n        const existing = items.find(i =&gt; i.id === item.id);\n        if (existing) {\n          set({ items: items.map(i =&gt; i.id === item.id ? { ...i, quantity: i.quantity + 1 } : i) });\n        } else {\n          set({ items: [...items, { ...item, quantity: 1 }] });\n        }\n      },\n      removeItem: (id) =&gt; set((state) =&gt; ({ items: state.items.filter(i =&gt; i.id !== id) })),\n      updateQuantity: (id, quantity) =&gt; set((state) =&gt; ({\n        items: state.items.map(i =&gt; i.id === id ? { ...i, quantity: Math.max(1, quantity) } : i)\n      })),\n      clearCart: () =&gt; set({ items: [] }),\n      total: () =&gt; get().items.reduce((sum, item) =&gt; sum + item.price * item.quantity, 0),\n    }),\n    { name: &#x27;cart-storage&#x27; }\n  )\n);\n<\/code><\/pre>\n<p>> \ud83d\udca1 \u4f7f\u7528 <code>persist<\/code> \u4e2d\u95f4\u4ef6\u53ef\u4ee5\u81ea\u52a8\u5c06\u8d2d\u7269\u8f66\u6570\u636e\u6301\u4e45\u5316\u5230 localStorage\u3002<\/p>\n<h3>2. \u5728\u7ec4\u4ef6\u4e2d\u4f7f\u7528<\/h3>\n<p>\u521b\u5efa <code>src\/zustand\/Cart.tsx<\/code>\uff1a<\/p>\n<pre><code class=\"language-tsx\">\nimport { useCartStore } from &#x27;.\/store&#x27;;\n\nexport function Cart() {\n  const { items, addItem, removeItem, updateQuantity, clearCart, total } = useCartStore();\n\n  return (\n    &lt;div&gt;\n      &lt;h2&gt;Zustand \u8d2d\u7269\u8f66&lt;\/h2&gt;\n      {items.length === 0 ? &lt;p&gt;\u8d2d\u7269\u8f66\u4e3a\u7a7a&lt;\/p&gt; : (\n        &lt;ul&gt;\n          {items.map(item =&gt; (\n            &lt;li key={item.id}&gt;\n              {item.name} - ${item.price} x {item.quantity}\n              &lt;button onClick={() =&gt; updateQuantity(item.id, item.quantity - 1)}&gt;-&lt;\/button&gt;\n              &lt;button onClick={() =&gt; updateQuantity(item.id, item.quantity + 1)}&gt;+&lt;\/button&gt;\n              &lt;button onClick={() =&gt; removeItem(item.id)}&gt;\u5220\u9664&lt;\/button&gt;\n            &lt;\/li&gt;\n          ))}\n        &lt;\/ul&gt;\n      )}\n      &lt;p&gt;\u603b\u4ef7: ${total()}&lt;\/p&gt;\n      &lt;button onClick={clearCart}&gt;\u6e05\u7a7a\u8d2d\u7269\u8f66&lt;\/button&gt;\n    &lt;\/div&gt;\n  );\n}\n<\/code><\/pre>\n<p>Zustand \u7684\u4f18\u52bf\u5728\u4e8e\uff1aAPI \u7b80\u6d01\uff0c\u65e0\u9700 Provider \u5305\u88f9\uff0c\u76f4\u63a5\u5728\u4efb\u4f55\u7ec4\u4ef6\u4e2d\u8c03\u7528 hook \u5373\u53ef\u3002\u6027\u80fd\u65b9\u9762\uff0cZustand \u9ed8\u8ba4\u4f7f\u7528 <code>Object.is<\/code> \u8fdb\u884c\u6d45\u6bd4\u8f83\uff0c\u53ea\u5728\u76f8\u5173\u72b6\u6001\u53d8\u5316\u65f6\u91cd\u65b0\u6e32\u67d3\u3002<\/p>\n<h2>\u65b9\u6848\u4e8c\uff1aJotai<\/h2>\n<p>Jotai \u91c7\u7528\u539f\u5b50\u5316\u72b6\u6001\u7ba1\u7406\uff0c\u6bcf\u4e2a\u72b6\u6001\u662f\u4e00\u4e2a\u72ec\u7acb\u7684 atom\uff0c\u901a\u8fc7\u7ec4\u5408\u5b9e\u73b0\u590d\u6742\u903b\u8f91\u3002<\/p>\n<h3>1. \u521b\u5efa atoms<\/h3>\n<p>\u521b\u5efa <code>src\/jotai\/store.ts<\/code>\uff1a<\/p>\n<pre><code class=\"language-typescript\">\nimport { atom } from &#x27;jotai&#x27;;\n\nexport interface CartItem {\n  id: number;\n  name: string;\n  price: number;\n  quantity: number;\n}\n\nexport const cartItemsAtom = atom&lt;CartItem[]&gt;([]);\n\nexport const addItemAtom = atom(\n  null,\n  (get, set, item: Omit&lt;CartItem, &#x27;quantity&#x27;&gt;) =&gt; {\n    const items = get(cartItemsAtom);\n    const existing = items.find(i =&gt; i.id === item.id);\n    if (existing) {\n      set(cartItemsAtom, items.map(i =&gt; i.id === item.id ? { ...i, quantity: i.quantity + 1 } : i));\n    } else {\n      set(cartItemsAtom, [...items, { ...item, quantity: 1 }]);\n    }\n  }\n);\n\nexport const removeItemAtom = atom(\n  null,\n  (get, set, id: number) =&gt; {\n    set(cartItemsAtom, get(cartItemsAtom).filter(i =&gt; i.id !== id));\n  }\n);\n\nexport const updateQuantityAtom = atom(\n  null,\n  (get, set, { id, quantity }: { id: number; quantity: number }) =&gt; {\n    set(cartItemsAtom, get(cartItemsAtom).map(i =&gt; i.id === id ? { ...i, quantity: Math.max(1, quantity) } : i));\n  }\n);\n\nexport const totalAtom = atom((get) =&gt; {\n  const items = get(cartItemsAtom);\n  return items.reduce((sum, item) =&gt; sum + item.price * item.quantity, 0);\n});\n<\/code><\/pre>\n<p>> \ud83d\udca1 Jotai \u7684 <code>atom<\/code> \u53ef\u4ee5\u5b9a\u4e49\u8bfb\u5199\u903b\u8f91\uff0c\u6d3e\u751f atom\uff08\u5982 <code>totalAtom<\/code>\uff09\u4f1a\u81ea\u52a8\u7f13\u5b58\uff0c\u53ea\u6709\u4f9d\u8d56\u53d8\u5316\u65f6\u624d\u91cd\u65b0\u8ba1\u7b97\u3002<\/p>\n<h3>2. \u5728\u7ec4\u4ef6\u4e2d\u4f7f\u7528<\/h3>\n<p>\u521b\u5efa <code>src\/jotai\/Cart.tsx<\/code>\uff1a<\/p>\n<pre><code class=\"language-tsx\">\nimport { useAtom, useAtomValue, useSetAtom } from &#x27;jotai&#x27;;\nimport { cartItemsAtom, addItemAtom, removeItemAtom, updateQuantityAtom, totalAtom } from &#x27;.\/store&#x27;;\n\nexport function Cart() {\n  const items = useAtomValue(cartItemsAtom);\n  const addItem = useSetAtom(addItemAtom);\n  const removeItem = useSetAtom(removeItemAtom);\n  const updateQuantity = useSetAtom(updateQuantityAtom);\n  const total = useAtomValue(totalAtom);\n\n  return (\n    &lt;div&gt;\n      &lt;h2&gt;Jotai \u8d2d\u7269\u8f66&lt;\/h2&gt;\n      {items.length === 0 ? &lt;p&gt;\u8d2d\u7269\u8f66\u4e3a\u7a7a&lt;\/p&gt; : (\n        &lt;ul&gt;\n          {items.map(item =&gt; (\n            &lt;li key={item.id}&gt;\n              {item.name} - ${item.price} x {item.quantity}\n              &lt;button onClick={() =&gt; updateQuantity({ id: item.id, quantity: item.quantity - 1 })}&gt;-&lt;\/button&gt;\n              &lt;button onClick={() =&gt; updateQuantity({ id: item.id, quantity: item.quantity + 1 })}&gt;+&lt;\/button&gt;\n              &lt;button onClick={() =&gt; removeItem(item.id)}&gt;\u5220\u9664&lt;\/button&gt;\n            &lt;\/li&gt;\n          ))}\n        &lt;\/ul&gt;\n      )}\n      &lt;p&gt;\u603b\u4ef7: ${total}&lt;\/p&gt;\n    &lt;\/div&gt;\n  );\n}\n<\/code><\/pre>\n<p>Jotai \u7684\u4f18\u52bf\u5728\u4e8e\uff1a\u9897\u7c92\u5ea6\u7ec6\uff0c\u53ea\u6709\u4f7f\u7528\u7279\u5b9a atom \u7684\u7ec4\u4ef6\u624d\u4f1a\u91cd\u65b0\u6e32\u67d3\u3002\u5bf9\u4e8e\u5927\u578b\u5e94\u7528\uff0c\u53ef\u4ee5\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u6e32\u67d3\u3002\u540c\u65f6\uff0cJotai \u4e0d\u9700\u8981 Provider\uff0c\u4f46\u652f\u6301 Context \u4f5c\u7528\u57df\u3002<\/p>\n<h2>\u65b9\u6848\u4e09\uff1aRedux Toolkit<\/h2>\n<p>Redux Toolkit \u662f Redux \u5b98\u65b9\u63a8\u8350\u7684\u5199\u6cd5\uff0c\u7b80\u5316\u4e86\u6837\u677f\u4ee3\u7801\u3002<\/p>\n<h3>1. \u521b\u5efa Slice<\/h3>\n<p>\u521b\u5efa <code>src\/redux\/store.ts<\/code>\uff1a<\/p>\n<pre><code class=\"language-typescript\">\nimport { createSlice, configureStore, PayloadAction } from &#x27;@reduxjs\/toolkit&#x27;;\n\ninterface CartItem {\n  id: number;\n  name: string;\n  price: number;\n  quantity: number;\n}\n\ninterface CartState {\n  items: CartItem[];\n}\n\nconst initialState: CartState = {\n  items: [],\n};\n\nconst cartSlice = createSlice({\n  name: &#x27;cart&#x27;,\n  initialState,\n  reducers: {\n    addItem: (state, action: PayloadAction&lt;Omit&lt;CartItem, &#x27;quantity&#x27;&gt;&gt;) =&gt; {\n      const existing = state.items.find(i =&gt; i.id === action.payload.id);\n      if (existing) {\n        existing.quantity += 1;\n      } else {\n        state.items.push({ ...action.payload, quantity: 1 });\n      }\n    },\n    removeItem: (state, action: PayloadAction&lt;number&gt;) =&gt; {\n      state.items = state.items.filter(i =&gt; i.id !== action.payload);\n    },\n    updateQuantity: (state, action: PayloadAction&lt;{ id: number; quantity: number }&gt;) =&gt; {\n      const item = state.items.find(i =&gt; i.id === action.payload.id);\n      if (item) {\n        item.quantity = Math.max(1, action.payload.quantity);\n      }\n    },\n    clearCart: (state) =&gt; {\n      state.items = [];\n    },\n  },\n});\n\nexport const { addItem, removeItem, updateQuantity, clearCart } = cartSlice.actions;\n\nexport const store = configureStore({\n  reducer: {\n    cart: cartSlice.reducer,\n  },\n});\n\nexport type RootState = ReturnType&lt;typeof store.getState&gt;;\nexport type AppDispatch = typeof store.dispatch;\n<\/code><\/pre>\n<h3>2. \u521b\u5efa hooks \u548c Provider<\/h3>\n<p>\u521b\u5efa <code>src\/redux\/hooks.ts<\/code>\uff1a<\/p>\n<pre><code class=\"language-typescript\">\nimport { TypedUseSelectorHook, useDispatch, useSelector } from &#x27;react-redux&#x27;;\nimport type { RootState, AppDispatch } from &#x27;.\/store&#x27;;\n\nexport const useAppDispatch = () =&gt; useDispatch&lt;AppDispatch&gt;();\nexport const useAppSelector: TypedUseSelectorHook&lt;RootState&gt; = useSelector;\n<\/code><\/pre>\n<p>\u5728 <code>src\/main.tsx<\/code> \u4e2d\u5305\u88f9 Provider\uff1a<\/p>\n<pre><code class=\"language-tsx\">\nimport { Provider } from &#x27;react-redux&#x27;;\nimport { store } from &#x27;.\/redux\/store&#x27;;\n\nReactDOM.createRoot(document.getElementById(&#x27;root&#x27;)!).render(\n  &lt;Provider store={store}&gt;\n    &lt;App \/&gt;\n  &lt;\/Provider&gt;\n);\n<\/code><\/pre>\n<h3>3. \u5728\u7ec4\u4ef6\u4e2d\u4f7f\u7528<\/h3>\n<p>\u521b\u5efa <code>src\/redux\/Cart.tsx<\/code>\uff1a<\/p>\n<pre><code class=\"language-tsx\">\nimport { useAppSelector, useAppDispatch } from &#x27;.\/hooks&#x27;;\nimport { addItem, removeItem, updateQuantity, clearCart } from &#x27;.\/store&#x27;;\n\nexport function Cart() {\n  const items = useAppSelector(state =&gt; state.cart.items);\n  const dispatch = useAppDispatch();\n  const total = items.reduce((sum, item) =&gt; sum + item.price * item.quantity, 0);\n\n  return (\n    &lt;div&gt;\n      &lt;h2&gt;Redux \u8d2d\u7269\u8f66&lt;\/h2&gt;\n      {items.length === 0 ? &lt;p&gt;\u8d2d\u7269\u8f66\u4e3a\u7a7a&lt;\/p&gt; : (\n        &lt;ul&gt;\n          {items.map(item =&gt; (\n            &lt;li key={item.id}&gt;\n              {item.name} - ${item.price} x {item.quantity}\n              &lt;button onClick={() =&gt; dispatch(updateQuantity({ id: item.id, quantity: item.quantity - 1 }))}&gt;-&lt;\/button&gt;\n              &lt;button onClick={() =&gt; dispatch(updateQuantity({ id: item.id, quantity: item.quantity + 1 }))}&gt;+&lt;\/button&gt;\n              &lt;button onClick={() =&gt; dispatch(removeItem(item.id))}&gt;\u5220\u9664&lt;\/button&gt;\n            &lt;\/li&gt;\n          ))}\n        &lt;\/ul&gt;\n      )}\n      &lt;p&gt;\u603b\u4ef7: ${total}&lt;\/p&gt;\n      &lt;button onClick={() =&gt; dispatch(clearCart())}&gt;\u6e05\u7a7a\u8d2d\u7269\u8f66&lt;\/button&gt;\n    &lt;\/div&gt;\n  );\n}\n<\/code><\/pre>\n<p>Redux \u7684\u4f18\u52bf\u5728\u4e8e\uff1a\u751f\u6001\u4e30\u5bcc\uff0c\u4e2d\u95f4\u4ef6\uff08\u5982 redux-saga\u3001redux-thunk\uff09\u6210\u719f\uff0c\u9002\u5408\u5927\u578b\u56e2\u961f\u548c\u590d\u6742\u72b6\u6001\u903b\u8f91\u3002\u4f46\u6837\u677f\u4ee3\u7801\u76f8\u5bf9\u8f83\u591a\u3002<\/p>\n<h2>\u6027\u80fd\u5bf9\u6bd4<\/h2>\n<p>\u6211\u4eec\u4f7f\u7528 React DevTools \u7684 Profiler \u6765\u6d4b\u91cf\u6e32\u67d3\u6027\u80fd\u3002\u5728\u6dfb\u52a0\u5546\u54c1\u65f6\uff0c\u4e09\u79cd\u65b9\u6848\u7684\u8868\u73b0\uff1a<\/p>\n<ul>\n<li><strong>Zustand<\/strong>\uff1a\u53ea\u6709\u4f7f\u7528 store \u7684\u7ec4\u4ef6\u91cd\u65b0\u6e32\u67d3\uff0c\u4f46\u82e5\u7ec4\u4ef6\u8ba2\u9605\u4e86\u6574\u4e2a store\uff0c\u5373\u4f7f\u53ea\u6539\u53d8\u90e8\u5206\u72b6\u6001\u4e5f\u4f1a\u91cd\u6e32\u67d3\u3002\u5efa\u8bae\u4f7f\u7528 selector \u7cbe\u786e\u9009\u62e9\u3002<\/li>\n<li><strong>Jotai<\/strong>\uff1a\u53ea\u91cd\u6e32\u67d3\u4f7f\u7528\u4e86\u53d8\u5316 atom \u7684\u7ec4\u4ef6\uff0c\u9897\u7c92\u5ea6\u6700\u7ec6\uff0c\u6027\u80fd\u6700\u4f73\u3002<\/li>\n<li><strong>Redux<\/strong>\uff1a\u901a\u8fc7 <code>useSelector<\/code> \u53ef\u4ee5\u7cbe\u786e\u9009\u62e9\uff0c\u4f46 Provider \u6a21\u5f0f\u53ef\u80fd\u5bfc\u81f4\u6839\u7ec4\u4ef6\u91cd\u6e32\u67d3\u3002\u4f7f\u7528 <code>React.memo<\/code> \u53ef\u4f18\u5316\u3002<\/li>\n<\/ul>\n<p>> \ud83d\udca1 \u5bf9\u4e8e\u5927\u591a\u6570\u4e2d\u5c0f\u578b\u5e94\u7528\uff0c\u6027\u80fd\u5dee\u5f02\u53ef\u4ee5\u5ffd\u7565\u3002\u4f46\u5728\u5927\u578b\u5e94\u7528\u4e2d\uff0cJotai \u7684\u539f\u5b50\u5316\u65b9\u6848\u80fd\u6709\u6548\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u6e32\u67d3\u3002<\/p>\n<h2>\u9009\u578b\u5efa\u8bae<\/h2>\n<p>| \u7ef4\u5ea6 | Zustand | Jotai | Redux Toolkit | |&#8212;&#8212;|&#8212;&#8212;&#8212;|&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;| | \u5b66\u4e60\u66f2\u7ebf | \u2b50 (\u4f4e) | \u2b50\u2b50 (\u4e2d) | \u2b50\u2b50\u2b50 (\u9ad8) | | \u6837\u677f\u4ee3\u7801 | \u5c11 | \u5c11 | \u4e2d | | \u6027\u80fd | \u597d | \u4f18\u79c0 | \u597d | | \u751f\u6001 | \u4e00\u822c | \u4e00\u822c | \u4e30\u5bcc | | \u9002\u5408\u573a\u666f | \u4e2d\u5c0f\u578b\u5e94\u7528\u3001\u5feb\u901f\u539f\u578b | \u9700\u8981\u7ec6\u7c92\u5ea6\u63a7\u5236\u3001\u590d\u6742\u6d3e\u751f\u72b6\u6001 | \u5927\u578b\u5e94\u7528\u3001\u56e2\u961f\u534f\u4f5c\u3001\u590d\u6742\u5f02\u6b65\u903b\u8f91 |<\/p>\n<p><strong>\u6211\u7684\u5efa\u8bae<\/strong>\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u4f60\u8ffd\u6c42\u6781\u7b80\u548c\u5f00\u53d1\u6548\u7387\uff0c\u9009 <strong>Zustand<\/strong>\u3002<\/li>\n<li>\u5982\u679c\u4f60\u9700\u8981\u7cbe\u7ec6\u5316\u7684\u72b6\u6001\u7ba1\u7406\uff0c\u5c24\u5176\u662f\u6d3e\u751f\u72b6\u6001\u591a\uff0c\u9009 <strong>Jotai<\/strong>\u3002<\/li>\n<li>\u5982\u679c\u4f60\u662f\u5927\u578b\u56e2\u961f\u6216\u9700\u8981\u5f3a\u5927\u7684\u4e2d\u95f4\u4ef6\u652f\u6301\uff0c\u9009 <strong>Redux Toolkit<\/strong>\u3002<\/li>\n<\/ul>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u901a\u8fc7\u8d2d\u7269\u8f66\u6848\u4f8b\uff0c\u5b8c\u6574\u6f14\u793a\u4e86 Zustand\u3001Jotai \u548c Redux Toolkit \u4e09\u79cd\u72b6\u6001\u7ba1\u7406\u65b9\u6848\u7684\u5b9e\u73b0\u3002\u6bcf\u79cd\u65b9\u6848\u5404\u6709\u4f18\u52a3\uff0c\u9009\u62e9\u65f6\u5e94\u6839\u636e\u9879\u76ee\u89c4\u6a21\u3001\u56e2\u961f\u7ecf\u9a8c\u548c\u5177\u4f53\u9700\u6c42\u6765\u5b9a\u3002\u5e0c\u671b\u8fd9\u7bc7\u6559\u7a0b\u80fd\u5e2e\u52a9\u4f60\u505a\u51fa\u660e\u667a\u7684\u9009\u578b\u51b3\u7b56\u3002<\/p>\n<p><strong>\u5ef6\u4f38\u9605\u8bfb<\/strong>\uff1a<\/p>\n<ul>\n<li>Zustand \u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/github.com\/pmndrs\/zustand<\/li>\n<li>Jotai \u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/jotai.org\/<\/li>\n<li>Redux Toolkit \u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/redux-toolkit.js.org\/<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5165\u5bf9\u6bd4 React \u4e09\u5927\u72b6\u6001\u7ba1\u7406\u65b9\u6848\uff1aZustand\u3001Jotai \u548c Redux\u3002\u901a\u8fc7\u5b8c\u6574\u7535\u5546\u8d2d\u7269\u8f66\u6848\u4f8b\uff0c\u624b\u628a\u624b\u6f14\u793a\u5404\u65b9\u6848\u7684\u5b9e\u73b0\u65b9\u5f0f\u3001\u6027\u80fd\u4f18\u5316\u6280\u5de7\u53ca\u9002\u7528\u573a\u666f\uff0c\u5e2e\u4f60\u505a\u51fa\u6700\u4f73\u9009\u578b\u51b3\u7b56\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[14,11,116,13,36,12],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry","category-3","category-4","tag-jotai","tag-react","tag-redux","tag-zustand","tag-36","tag-12"],"_links":{"self":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":0,"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"wp:attachment":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}