# @alevnyacow/shared-react-variables

> Global mutable useState for React. For real!

Latest version **2.0.5** (published 2022-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @alevnyacow/shared-react-variables
pnpm add @alevnyacow/shared-react-variables
yarn add @alevnyacow/shared-react-variables
bun add @alevnyacow/shared-react-variables
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2022-08-29 |
| First published | 2022-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 15.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | alevnyacow |
| Maintainers | alevnyacow |
| Keywords | react, state, state management, global state |

## Links

- npm: https://www.npmjs.com/package/@alevnyacow/shared-react-variables
- Repository: https://github.com/alevnyacow/shared-react-variables
- Homepage: https://codesandbox.io/s/react-shared-variables-example-f7feo7
- Issues: https://github.com/alevnyacow/shared-react-variables/issues
- npm.io page: https://npm.io/package/@alevnyacow/shared-react-variables

## Dependencies (2)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [@alevnyacow/deep-js-proxy](https://npm.io/package/@alevnyacow/deep-js-proxy.md) ^1.0.1

## 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

- 2.0.5 (latest) — 2022-08-29
- 2.0.4 — 2022-08-29
- 2.0.3 — 2022-03-28
- 2.0.2 — 2022-03-24
- 2.0.1 — 2022-03-22
- 2.0.0 — 2022-03-21
- 1.0.4 — 2022-03-13
- 1.0.3 — 2022-03-12
- 1.0.2 — 2022-03-11
- 1.0.1 — 2022-03-11
- 1.0.0 — 2022-03-11
- 0.0.3 — 2022-03-11
- 0.0.2 — 2022-03-11
- 0.0.1 — 2022-03-11

## README

# Shared React variables

![npm](https://img.shields.io/npm/v/@alevnyacow/shared-react-variables)
![GitHub](https://img.shields.io/github/license/alevnyacow/shared-react-variables)
![GitHub last commit](https://img.shields.io/github/last-commit/alevnyacow/shared-react-variables)
![npm](https://img.shields.io/npm/dm/@alevnyacow/shared-react-variables)
![GitHub top language](https://img.shields.io/github/languages/top/alevnyacow/shared-react-variables)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

## ✨ **About**

Shared React variables provide you easy and comfortable global state management based on hooks. You can treat it like a **global mutable useState**. Isn't it awesome?

## 🔍 **Example**

```tsx
import { createUseSharedVariable } from "@alevnyacow/shared-react-variables"; 

const [useTimer] = createUseSharedVariable({ ticks: 0 });

const Timer = () => {
    const timer = useTimer();
    useEffect(() => {
        setInterval(() => {
            timer.ticks++;
        }, 1000);
    }, []);

    return <div>{timer.ticks}</div>
};

const AnotherTimerWithSameState = () => {
    // using pretty same timer in another place
    const timer = useTimer();

    return <div>{timer.ticks}</div>
};
```

## 💡 **Codesandbox**

https://codesandbox.io/s/react-shared-variables-example-f7feo7

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