A React hook used for managing state and Storage simultaneously.
Use npm to install bjork_useStorage or copy the code manually form github.
> npm i bjork_useStorage
useStorage takes three params:
- type ('local' | 'session' | 'cookie'): Storage type.
- key (string)
- initalValue (@default '').
The returned "set" takes two parameters, key and value. If the chosen type is cookie, then the returned "set" also takes an optional third parameter that configures how the cookie is formatted, for more information check out the dependency cookie-helper.
import useStorage from 'bjork_usestorage'
const [ state, setState ] = useStorage(type, key, initalvalue?)
Pull requests are welcome. For any considerable changes, please open an issue first to discuss what you would like to change.