bjork_usestorage
v1.2.3
Published
A react hook for managing state and storage
Downloads
7
Readme
What is this?
A React hook used for managing state and Storage simultaneously, effortlessly.
Install
Use npm to install bjork_useStorage or copy the code manually form github.
> npm i bjork_useStorage
Usage
Utilizes and, therefor, functions like Reacts useState. However, useStorage also take three params:
- type (string). Which only accepts one of three strings "local", "session" or "cookie".
- key (string)
- initalValue (@default "").
The returned "set" takes two parameters, key and value. Also, if the chosen type is cookie, then the returned "set" also takes an optional third parameter that configures how the cookie is packaged, for more information check out the dependency bjork_cookie.
> import useStorage from 'bjork_usestorage'
>
> const [ state, setState ] = useStorage(type, key, initalvalue?)
Contribution
Pull requests are welcome. For any considerable changes, please open an issue first to discuss what you would like to change.