Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/embbnux/use-global-storage

React hook to connect storage and state
https://github.com/embbnux/use-global-storage

Last synced: 28 days ago
JSON representation

React hook to connect storage and state

Awesome Lists containing this project

README

        

# use-global-storage

[![NPM Version](https://img.shields.io/npm/v/use-global-storage.svg?style=flat-square)](https://www.npmjs.com/package/use-global-storage)

React Hook to connect storage and state. You can use this as a global state manager in React.

## Install

via npm:

```
npm install use-global-storage
```

via yarn:

```
yarn add use-global-storage
```

## Usage

```js
import useGlobalStorage from 'use-global-storage';

const useStorage = useGlobalStorage({
storageOptions: { name: 'test-db' }
});

const Counter = () => {
const [state, setState] = useStorage('counter');
return (



Counter:
{state || 0}


setState(state + 1)}>
+1 to global


);
};
```