# schummar-state

> (React) state library

Latest version **0.4.8** (published 2023-11-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install schummar-state
pnpm add schummar-state
yarn add schummar-state
bun add schummar-state
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.4.8 |
| Published | 2023-11-17 |
| First published | 2020-12-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 171.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Marco Schumacher |
| Maintainers | schummar |

## Links

- npm: https://www.npmjs.com/package/schummar-state
- Repository: https://github.com/schummar/schummar-state
- Homepage: https://github.com/schummar/schummar-state#readme
- Issues: https://github.com/schummar/schummar-state/issues
- npm.io page: https://npm.io/package/schummar-state

## Dependencies (1)

- [fast-equals](https://npm.io/package/fast-equals.md) ^4.0.1

## Recent versions

- 0.4.8 (latest) — 2023-11-17
- 0.5.4 (next) — 2023-01-16
- 0.2.1-experimental-21 (beta) — 2022-07-14
- 0.4.7 — 2023-02-28
- 0.5.2 — 2023-01-16
- 0.5.1 — 2023-01-16
- 0.5.0 — 2023-01-16
- 0.4.6 — 2022-11-08
- 0.4.5 — 2022-11-08
- 0.4.4 — 2022-09-26
- 0.4.3 — 2022-08-04
- 0.4.2 — 2022-07-20
- 0.2.1-experimental-20 — 2022-07-13
- 0.4.1 — 2022-06-08
- 0.4.0 — 2022-05-30
- … 67 more at https://npm.io/package/schummar-state/versions

## README

[![npm badge](https://badgen.net/npm/v/schummar-state)](https://www.npmjs.com/package/schummar-state)
[![bundlephobia badge](https://badgen.net/bundlephobia/minzip/schummar-state)](https://bundlephobia.com/result?p=schummar-state)

Lighweight React hooks based state library.
Heavily inspired by [pullstate](https://github.com/lostpebble/pullstate)

# Getting started

### Install

```
npm install schummar-state
```

### Create a store

```ts
import { Store } from 'schummar-state';

export const store = new Store({
  counter: 0,
});
```

You can easily use multiple stores in parallel.

### Use store in a component

```tsx
import store from './store.ts';

export function App() {
  const counter = store.useState((state) => state.counter);

  return (
    <div>
      <div>Counter: {counter}</div>
    </div>
  );
}
```

### Update a store

```tsx
import store from './store.ts';

export function App() {
  const counter = store.useState((state) => state.counter);

  const increment = () =>
    store.update((state) => {
      state.counter++;
    });

  return (
    <div>
      <div>Counter: {counter}</div>
      <button onClick={increment}>Increment</button>
    </div>
  );
}
```

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