https://github.com/termosa/create-global-state-hook
Creates a hook like useState but all instances will have a single shared storage
https://github.com/termosa/create-global-state-hook
Last synced: 12 months ago
JSON representation
Creates a hook like useState but all instances will have a single shared storage
- Host: GitHub
- URL: https://github.com/termosa/create-global-state-hook
- Owner: termosa
- Created: 2021-08-22T14:29:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-22T14:29:53.000Z (almost 5 years ago)
- Last Synced: 2025-06-09T12:47:27.760Z (about 1 year ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# crete-global-state-hook
Creates a hook like useState but all instances will have a single shared storage
## Example
```js
import creteGlobalStateHook from 'crete-global-state-hook'
const useGlobalCounter = createGlobalStateHook(0)
export default function GlobalCounter() {
const [count, setCount] = useGlobalCounter()
return (
setCount(count - 1)} />
{count}
setCount(count + 1)} />
)
}
```