Open palfaro91 opened 3 years ago
You could use something like getState
and then transforming it yourself:
getState(storage) {
if (storage.foo?.user) {
storage.foo.account = Object.assign({}, storage.foo.user)
delete storage.foo.user
}
return storage
}
(not tested)
vuex-persistedstate
version: 4.0.0-beta.3node
version: 13.12npm
(oryarn
) version: 6.14.4Relevant code or config
What you did: I renamed a key in my state What happened: App crashed because the updated key didn't exist in localstorage state
Reproduction sandbox:
Problem description: I renamed one key in my state definition and since the state was loaded from local storage the new key was not in the state. What's the proper way of updating a key name? for example my state definition originally looked like this
so my local storage looked like
{ foo: {user: { first_name: '' } } }
i then updated my state definition to
and references to
foo.user.first_name
were updated tofoo.account.first_name
. My app crashes here because state still has foo.user. How do i go about updating my local storage state so that it has the new key? Suggested solution: