# react-gsm-hook

> Global state management (with namespaces :) and hooks)

Latest version **1.0.5** (published 2019-10-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-gsm-hook
pnpm add react-gsm-hook
yarn add react-gsm-hook
bun add react-gsm-hook
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2019-10-08 |
| First published | 2019-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | yhorm |
| Maintainers | yhorm |
| Keywords | react, hook, global, state, management, namespace |

## Links

- npm: https://www.npmjs.com/package/react-gsm-hook
- Repository: https://github.com/cyearsley/react-gsm-hook
- Homepage: https://github.com/cyearsley/react-gsm-hook#readme
- Issues: https://github.com/cyearsley/react-gsm-hook/issues
- npm.io page: https://npm.io/package/react-gsm-hook

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2019-10-08
- 1.0.4 — 2019-10-08
- 1.0.3 — 2019-10-08
- 1.0.2 — 2019-10-07
- 1.0.1 — 2019-10-07
- 1.0.0 — 2019-10-07

## README

## React Global State Management with namespaces 😆 and hooks 🎣

![alt text](https://media1.giphy.com/media/QfMErvIH7r60M/giphy.gif?cid=790b7611f36851bd35fb51bf72d0716fd7addd14e2e7c9a7&rid=giphy.gif "HOOK")

> For a full example, check out [this code sandbox](https://codesandbox.io/embed/patient-wildflower-kujt1)!

> This package allows the use of global state management with ease.
> It affords the ability to define global state with namespaces.

### Example (TypeScript):
```
interface IPerson {
	name: string;
	age: number;
}

const [person, setPerson] = useGlobalState<IPerson>("person", {
	name: "The cool guy",
	age: 36
});
```

### Example (JavaScript):
```
const [person, setPerson] = useGlobalState("person", {
	name: "The cool guy",
	age: 36
});
```
These examples will define `the cool guy` in the namespace `person`.

### If no namespace is provided, the namespace will default to `default`
```
const [account, setAccount] = useGlobalState<IAccount>(); // namespace defaults to "default"
```

### To use the hook, you need to specify the provider at the app level:
```
const App: React.FC = () => {
  return (
    <div className="App">
      <GlobalStateProvider>
        {/* content ... */}
      </GlobalStateProvider>
    </div>
  );
}
```

---
_Source: https://npm.io/package/react-gsm-hook · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
