# @hamidreza.nateghi/use-state

> useState as a store

Latest version **1.0.3** (published 2023-03-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install @hamidreza.nateghi/use-state
pnpm add @hamidreza.nateghi/use-state
yarn add @hamidreza.nateghi/use-state
bun add @hamidreza.nateghi/use-state
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-03-12 |
| First published | 2023-03-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hamidreza Nateghi |
| Maintainers | hamidreza.nateghi |
| Keywords | react, use, store, state, useState, use-state, redux, zustand, context, management, hook |

## Links

- npm: https://www.npmjs.com/package/@hamidreza.nateghi/use-state
- npm.io page: https://npm.io/package/@hamidreza.nateghi/use-state

## Dependencies (1)

- [use-sync-external-store](https://npm.io/package/use-sync-external-store.md) ^1.2.0

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2023-03-12
- 1.0.2 — 2023-03-11
- 1.0.1 — 2023-03-11
- 1.0.0 — 2023-03-11

## README

# useState as a store

You can try a live demo [here](https://).

```bash
npm install @hamidreza.nateghi/use-state # or yarn add @hamidreza.nateghi/use-state
```

## First create a store

```jsx
import create from '@hamidreza.nateghi/use-state'

const useState = create({
  count: 0,
  todos: [],
  theme: 'dark',
})
```

## Then bind your components, and that's it!

```jsx
function App() {
  const [theme] = useState('theme')
  return <h1>Theme: {theme}</h1>
}

function ThemeController() {
  const [theme, setTheme] = useState('theme')
  return <button onClick={() => setTheme('light')}>{theme}</button>
}
```

---
_Source: https://npm.io/package/@hamidreza.nateghi/use-state · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
