# @naporin0624/react-flow

> > TODO: description

Latest version **1.0.7** (published 2022-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @naporin0624/react-flow
pnpm add @naporin0624/react-flow
yarn add @naporin0624/react-flow
bun add @naporin0624/react-flow
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2022-07-25 |
| First published | 2021-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | naporin0624 |
| Maintainers | naporin0624 |

## Links

- npm: https://www.npmjs.com/package/@naporin0624/react-flow
- Homepage: https://github.com/naporin0624/packages/tree/main/packages/react-flow#react-flow
- npm.io page: https://npm.io/package/@naporin0624/react-flow

## Dependencies (2)

- [use-sync-external-store](https://npm.io/package/use-sync-external-store.md) ^1.0.0
- [@naporin0624/simple-store](https://npm.io/package/@naporin0624/simple-store.md) ^0.1.4

## Recent versions

- 1.0.7 (latest) — 2022-07-25
- 1.0.6 — 2022-07-14
- 1.0.5 — 2022-04-10
- 1.0.5-alpha.0 — 2022-04-10
- 1.0.4-alpha.0 — 2022-04-10
- 1.0.3 — 2022-04-10
- 1.0.2 — 2022-04-09
- 1.0.1 — 2022-04-08
- 1.0.0 — 2022-04-08
- 1.0.0-alpha.0 — 2022-04-02
- 0.2.1 — 2022-03-22
- 0.2.0 — 2022-03-22
- 0.1.4 — 2022-02-19
- 0.1.3 — 2022-01-22
- 0.1.2 — 2022-01-22
- … 15 more at https://npm.io/package/@naporin0624/react-flow/versions

## README

# `react-flow`

A library that connects rxjs to React.

Observables registered with the same key are subscribed only once in total.

[![Image from Gyazo](https://i.gyazo.com/0b5f38a4c3e943eff75ebdfc8a6ba16e.gif)](https://gyazo.com/0b5f38a4c3e943eff75ebdfc8a6ba16e)

## Usage

```jsx
import ReactDOM from "react-dom";
import { Subject, scan } from "rxjs";
import { Provider, useFlow } from "@naporin0624/react-flow";

const root = new Subject<number>();
const counter$ = root.pipe(
  scan<number, number>((acc, value) => acc + value, 0)
);
const increment = () => root.next(1);
const decrement = () => root.next(-1);

const Counter = () => {
  const counter = useFlow("counter", counter$) ?? 0;

  return (
    <div>
      <p>counter: {counter}</p>
      <div>
        <button onClick={increment}>+</button>
        <button onClick={decrement}>-</button>
      </div>
    </div>
  );
};

// The counter subscribe is called only once.
const App = () => {
  return (
    <Provider>
      <div>
        <p>counter1</p>
        <Counter />
      </div>
      <div>
        <p>counter2</p>
        <Counter />
      </div>
    </Provider>
  );
};

ReactDOM.render(<App />, document.getElementById("root"));
```

## LICENSE

MIT

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