Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useLocalStorage: not updating the value #609

Open
pikax opened this issue Oct 15, 2020 · 0 comments
Open

useLocalStorage: not updating the value #609

pikax opened this issue Oct 15, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@pikax
Copy link
Owner

pikax commented Oct 15, 2020

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

@pikax pikax added the bug Something isn't working label Oct 15, 2020
@pikax pikax self-assigned this Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant