My setitem and getItem working properly but when i refresh page data diappeard
CodePudding user response:
before you reload, do you check the local storage and you see the data there. Plus you may want to add more details.
CodePudding user response:
I’m not sure about this, but i’m seeing that at line 37, you wrote an hook that fires at every update(reload) and there isn’t any sorta of check. So if ur contacts is null or undefined or an empty string when the page reload, this will set you item in localstorage as empty.
CodePudding user response:
Well, that is the point of LocalStorage. It only stores until the page gets reloaded.
Maybe you can try using Cookies with limited time instead?
Another way would be Server-handled sessions or sessions via JWT