Zustand persist individual slices (zustand-x library instead?)

Hi guys! Anyone used this 3rd party abstraction of Zustand? I want to know if I might be running into any pitfalls https://github.com/udecode/zustand-x An issue I have with the base Zustand library is with persisting only specific slices in my global store. To accomplish this I have to either create a separate store or use the partialize function which seems very boilerplatey and annoying to work with on a bigger scale (I might be wrong here, this is just what I'm getting from the documentation) However with the zustand-x library (formerly known as zustood), a lot of boilerplate is removed, and you can persist individual stores. Example (pay attention that you don't need to create getters or setters when writing your stores either - but you can extend both the selectors and actions on the store if you need to):
export const authStore = createStore('auth')(
{
session: undefined,
user: undefined,
},
{
persist: {
name: 'auth',
storage: createJSONStorage(() => zustandStorage),
},
},
);
export const authStore = createStore('auth')(
{
session: undefined,
user: undefined,
},
{
persist: {
name: 'auth',
storage: createJSONStorage(() => zustandStorage),
},
},
);
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server