Created
May 12, 2024 03:02
-
-
Save Blithe-Chiang/6bb07a94ae9fc67d1ff1af2d45b3ae1a to your computer and use it in GitHub Desktop.
zustand简单封装
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deps: zustand, immer | |
import { create } from "zustand"; | |
import { immer } from "zustand/middleware/immer"; | |
export type TStore<T> = ReturnType<typeof createStore<T>> | |
export function createStore<T>(initState: T) { | |
return create<T>()( | |
immer((set) => ({ | |
...initState | |
})) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment