Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/embbnux/use-global-storage
- Owner: embbnux
- Created: 2019-04-22T08:40:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:52:57.000Z (almost 2 years ago)
- Last Synced: 2024-10-05T02:30:52.532Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://embbnux.github.io/use-global-storage-demo/
- Size: 578 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
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
);
};
```