mirror of
https://github.com/KazooTTT/kazoottt-blog-v2.git
synced 2025-06-23 18:51:30 +08:00
Update docs and sort content
This commit is contained in:
@ -5,7 +5,7 @@ published: true
|
||||
toWexin: null
|
||||
toJuejin: null
|
||||
toZhihu: null
|
||||
title: 分享一下我的zustand错误使用案例
|
||||
title: 分享一下我的 zustand 错误使用案例
|
||||
date: 2024-12-17T00:00:00.000Z
|
||||
author: KazooTTT
|
||||
tags:
|
||||
@ -23,7 +23,7 @@ description: >-
|
||||
来只获取需要的数据。同时,应该遵循最小粒度原则,只获取需要的数据,而不是使用多个 store 去存储不同的 state。另外,与 UI 无关的 state
|
||||
不需要通过 selector 获取,正确的做法是直接在 handleSave 方法内部访问 store。
|
||||
date_created: 20250207
|
||||
date_modified: 20250304
|
||||
date_modified: 20250313
|
||||
banner: 'https://pictures.kazoottt.top/2025/02/20250201-og-1738417688145.png'
|
||||
---
|
||||
|
||||
@ -128,15 +128,15 @@ const CurrentCamera: React.FC = () => {
|
||||
|
||||
> [!quote]
|
||||
> Recommended patterns 推荐模式
|
||||
>
|
||||
>
|
||||
> Single store 单一存储
|
||||
>
|
||||
>
|
||||
> Your applications global state should be located in a single Zustand store.
|
||||
>
|
||||
>
|
||||
> 你的应用程序的全局状态应该位于一个单一的 Zustand 存储中。
|
||||
>
|
||||
>
|
||||
> If you have a large application, Zustand supports splitting the store into slices.
|
||||
>
|
||||
>
|
||||
> 如果你有一个大型应用程序,Zustand 支持将存储拆分为切片。
|
||||
|
||||
## 错误用法 4 与 UI 无关的 state 通过 selector 获取
|
||||
@ -183,6 +183,6 @@ const ComponentA = () => {
|
||||
|
||||
[Zustand](<https://zustand-demo.pmnd.rs/>)
|
||||
|
||||
[master 分支下的 notes/zustand 学习笔记.md --- notes/zustand学习笔记.md at master · puxiao/notes](<https://github.com/puxiao/notes/blob/master/zustand%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0.md>)
|
||||
[master 分支下的 notes/zustand 学习笔记。md --- notes/zustand 学习笔记。md at master · puxiao/notes](<https://github.com/puxiao/notes/blob/master/zustand%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0.md>)
|
||||
|
||||
[如何有效率地管理 React 局部狀態? 這次我選擇了 Zustand! | Bosh 的技術探索筆記](<https://notes.boshkuo.com/docs/React/zustand#%E7%82%BA%E4%BD%95%E9%81%B8%E6%93%87%E4%BD%BF%E7%94%A8-zustand->)
|
||||
|
Reference in New Issue
Block a user