astoilkov / use-local-storage-state

React hook that persists data in localStorage
MIT License
1.09k stars 39 forks source link

Enhancment: use window.name as fallback #25

Closed tilman closed 3 years ago

tilman commented 3 years ago

Hey, just wanted to discuss the Idea of using window.name as a fallback instead of a global variable.

window.name would have the advantage of being persistent for the whole javascript session (in particular for a page reload; but not across tabs) and is still available even if cookies are turned off.

If you think that would be a better solution I would be happy to create a merge request.

Here is some more information about window.name: https://www.thomasfrank.se/sessionvars.html

astoilkov commented 3 years ago

That's an interesting idea. I didn't know window.name worked like that. Can you help me by answering some questions?

kolben commented 3 years ago

https://developer.mozilla.org/en-US/docs/Web/API/Window/name

Wouldn't recommend it :smile:

astoilkov commented 3 years ago

@kolben I read the article. Thanks.

Why you wouldn't recommend it? What are the reasons? Thanks.

kolben commented 3 years ago
astoilkov commented 3 years ago

@kolben Yep. That's pretty definitive. Closing this issue then. Thanks!