Open Magiczne opened 3 years ago
Can you make a sample github repo with a small contrivied example that faces this issue. I would really love to checkout on my machine and actually debug this properly.
@championswimmer - https://github.com/Magiczne/vuex-persist-bug-poc
Click the button and it will fail spectacularly:
Comment line 40 in the src/store/index.ts and it's working completely fine.
I'm facing this issue too.! Another place is in reducer.. it uses deepmerge and the class instance is dead and it's custom stringifying logic is no longer present
Can we have an option to do this without deepmerge?
I have ended up writing this functionality on my own in the projects I'm using it with, caues it looks that library is somehow abandoned.
I also couldn't find any reason besides #64 why lodash was replaced when it was working perfectly fine.
As present in the image, i had to do three things to overcome this.
I have a similar issue.
I created store including Map
and Set
value in state, but both are converted to empty objects.
import Vuex from 'vuex';
import VuexPersistence from 'vuex-persist';
const store = new Vuex.Store({
state: {
// Expected empty Map, but actually object
map: new Map(),
set: new Set(),
},
});
const persist = new VuexPersistence({
storage: window.localStorage,
reducer: (state) => ({ map: state.map }),
}).plugin(store);
This is caused by the behavior of merging object by deepmerge, which replaced lodash.merge from 3.x.
I think another library like just-extend or something should be used. just-extend is a zero-dependency package, so its bundle size is tiny.
After updating to vuex-persist 3.1.3 modules that are not related in any way to vuex-persist plugin are broken when they're using classes as a part of state. Also i'm using vuex-module-decorators.
For example:
On the application start it throw an error that
foo.bar()
is not a function. It would make sense when the module would be loaded byvuex-persist
but it it not so it should be not touched.Everything worked fine when the backend besides merging was handled by lodash. Everything broke after moving to deepmerge.
What it the solution to this? Temporarily we're using older version but that's not a good option for a long time.