bjork_usestorage

1.2.3 • Public • Published

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:

  1. type (string). Which only accepts one of three strings "local", "session" or "cookie".
  2. key (string)
  3. 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.

Licence

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i bjork_usestorage

Weekly Downloads

6

Version

1.2.3

License

MIT

Unpacked Size

4.39 kB

Total Files

4

Last publish

Collaborators

  • emileinarsen