Replies: 1 comment
-
What is the Could you provide a minimal reproduce? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've tried to update and remove persisted data in the storage by setting the state to null, but the data in storage still exist.
I'm using Nuxt 3.
In plugin/piniapersistedstate.ts
export default defineNuxtPlugin((nuxtApp) => { nuxtApp.$pinia.use( createPersistedStatePlugin({ serialize: (state) => stringify(state), deserialize: (state) => JSON.parse(state), storage: { getItem: async (key) => { return localforage.getItem(key); }, setItem: async (key, value) => { return localforage.setItem(key, value); }, removeItem: async (key) => { return localforage.removeItem(key); }, }, }) ); });
In store/user.ts
`export const user = defineStore("user", () => {
const credentials = ref<any | null>(null);
const setUser = (value: any) => {
credentials.value = value;
};
const removeUser = () => {
credentials.value = null;
};
return { credentials, setUser, removeUser };
});`
Beta Was this translation helpful? Give feedback.
All reactions