# rewow

> Declarative state management for React

Latest version **0.0.11** (published 2020-02-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install rewow
pnpm add rewow
yarn add rewow
bun add rewow
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.11 |
| Published | 2020-02-12 |
| First published | 2020-02-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 69.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | linq2js |
| Maintainers | linq2js |
| Keywords | flux, react, store, state, state-management, state-manager, flow |

## Links

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

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

- 0.0.11 (latest) — 2020-02-12
- 0.0.10 — 2020-02-12
- 0.0.9 — 2020-02-11
- 0.0.8 — 2020-02-11
- 0.0.7 — 2020-02-11
- 0.0.5 — 2020-02-11
- 0.0.4 — 2020-02-10
- 0.0.3 — 2020-02-10
- 0.0.2 — 2020-02-10
- 0.0.1 — 2020-02-10

## README

# rewow

Declarative state management for React

## Counter App using pure function to modify state

```jsx harmony
import React from 'react';
import {createStore, useStore} from 'rewow';
const store = createStore({count: 0});
// an action is pure function, just returns next state
const Increase = (payload, state) => ({...state, count: state.count + 1});
const App = () => {
  const {count, dispatch} = useStore(store, state => ({count: state.count}));
  return (
    <>
      <h1>{count}</h1>
      <button onClick={() => dispatch(Increase)}>Increase</button>
    </>
  );
};
```

## Using declarative syntax instead of pure state mutating function

```jsx harmony
import {mutate, add} from 'rewow';
const Increase = () => mutate({count: add(1)});
```

## Conditional state mutating

```jsx harmony
import {mutate, add, cond} from 'rewow';
const isEvent = value => value % 2 === 0;
const Increase = () => mutate({count: cond({if: isEvent, then: add(1)})});
```

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