Skip to content

useLocalStorage: not updating the value #609

Open
@pikax

Description

@pikax

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions