# react-ezglobalstate-hook

> A reactive state with localstorage and SWR

Latest version **0.1.4** (published 2020-07-15) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2020-07-15 |
| First published | 2020-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Felipe Correa |
| Maintainers | felps.dev |

## Links

- npm: https://www.npmjs.com/package/react-ezglobalstate-hook
- Repository: https://github.com/felps-dev/react-ezglobalstate-hook
- npm.io page: https://npm.io/package/react-ezglobalstate-hook

## Dependencies (1)

- [swr](https://npm.io/package/swr.md) ^0.2.3

## Recent versions

- 0.1.4 (latest) — 2020-07-15
- 0.1.3 — 2020-07-15
- 0.1.2 — 2020-07-15
- 0.1.1 — 2020-07-15
- 0.1.0 — 2020-07-15

## README

# React-EZGlobalState-Hook

A reactive state with localstorage and SWR.

## Reference

`npm i --save react-ezglobalstate-hook`  
or  
`yarn add react-ezglobalstate-hook`

```javascript
import {
    useGlobalState,
    setGlobalState
} from 'react-ezglobalstate-hook';
```
### useGlobalState(key: string, initialValue: any):
#
```javascript
const myState = useGlobalState("unique_key", "default");
```  

### setGlobalState(key: string, value: any):
#
```javascript
setGlobalState("unique_key", "value");
```
## Example

```javascript
import {
    useGlobalState,
    setGlobalState
} from 'react-ezglobalstate-hook';

export default function Component(){
    //Is this case, Hello World is the primary value if we
    //never had stored this value before.
    const myState = useGlobalState("myState", "Hello World");

    function handleChange(){
        setGlobalState("myState", "Good Bye World");
    }

    return (
        <div>
            <span>{`Actual value for myState is: ${myState}`}</span>
            <button onClick={handleChange}>Change Name</button>
        </div>
    )
}

```

License
----

MIT

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