championswimmer / vuex-persist

A Vuex plugin to persist the store. (Fully Typescript enabled)
http://championswimmer.in/vuex-persist
MIT License
1.67k stars 116 forks source link

Fix this.mergeOption being null in RESTORE_MUTATION in strictmode #242

Closed oscarchilds closed 2 years ago

oscarchilds commented 2 years ago

Fix for issue #213, where I think the issue is explained best, but I'll give it my own try below

RESTORE_MUTATION function contains a reference to this.mergeOption, but this seems to be for a different context, causing mergeOption to always be null when using the RESTORE_MUTATION

This creates an issue when restoring arrays from localStorage. Deepmerge defaults to a merge behaviour when merging arrays, but vuex-persist defaults to 'replaceArrays', which ends up not being respected as mergeOption is null, so Deepmerge reverts to it's default of merging arrays.

I've put together an example of the issue in action here

Thanks

xmile1 commented 2 years ago

Hi @championswimmer @oscarchilds , Thanks for this library, It seems this change and the others after it were not released. The last release was 3.1.3 on npm. was this intentional?

oscarchilds commented 2 years ago

NPM has not seen a release for a while, even though a number of changes have been brought into master for this package. I'd recommend forking your own solution or moving onto another package if we don't see another release to NPM