Replies: 2 comments
|
The v5 persist middleware API is mostly the same but with updated type signatures and a few changes: import { create } from "zustand"
import { persist, createJSONStorage } from "zustand/middleware"
const useStore = create(
persist(
(set, get) => ({
count: 0,
increment: () => set(state => ({ count: state.count + 1 })),
}),
{
name: "my-storage-key",
storage: createJSONStorage(() => localStorage),
partialize: (state) => ({ count: state.count }),
}
)
)Key v5 changes:
Full docs: https://zustand.docs.pmnd.rs/integrations/persisting-store-data |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
#2659 (comment) @cschanhniem
All reactions