rehooks / local-storage

React hook which syncs localStorage[key] with the comp.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can we include set data for key of localStorage to this project?

pierreneter opened this issue · comments

It look like full API of localStorage:

localStorage.setItem()
localStorage.getItem()
localStorage.removeItem()

with getItem is a React Hook

We don't aim to replicate the local storage api, instead just want to keep the component in sync with the storage. So you can set items normally ( there won't be any benefit of using hooks, if there is let me know - apart from the obvious good api thing)

I am probably missing a purpose of this hook. How would data get into localStorage in a first place or how do you update them? You need to have your own useEffect that replicates it from your own state? It would make sense to return observable that can be mutated and sync data back to localStorage. Otherwise I don't know why...

This is fixed as of version 1.2.0