useLocalStorage: not updating the value
pikax opened this issue · 0 comments
If the initial state is { [key]: undefined }, it's committed to localStorage as "{}".
If you don't mutate it, and reload, the reactivity breaks.
You can't assign to deep variables, and you can't watch them.
https://codesandbox.io/s/vue-composable-localstorage-reloaded-empty-state-bug-i1yqd
https://i1yqd.csb.app/
Without clicking on the buttons, reload the page.
Then click on the two first buttons ( they are the ones that mutate properties of the object ).
The first button is broken until you click the third, upon which the entire object is replaced, and reactivity is revived.
Pre existing "empty" localStorage states breaks it.
https://codesandbox.io/s/vue-composable-localstorage-reloaded-empty-state-bug-forked-qgrsk