# react-hooks-state

> React state management plugin using new hooks

Latest version **1.0.1** (published 2019-01-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-hooks-state
pnpm add react-hooks-state
yarn add react-hooks-state
bun add react-hooks-state
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-01-27 |
| First published | 2019-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jyoti Prakash |
| Maintainers | jppradhan |
| Keywords | react, state, hooks, state |

## Links

- npm: https://www.npmjs.com/package/react-hooks-state
- npm.io page: https://npm.io/package/react-hooks-state

## Dependencies (4)

- [@types/node](https://npm.io/package/@types/node.md) ^10.12.18
- [@types/react](https://npm.io/package/@types/react.md) ^16.7.18
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.2.5
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^16.0.11

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

- 1.0.1 (latest) — 2019-01-27
- 1.0.0 — 2019-01-27

## README

# react-hooks-state
React state management hooks

Implemented state management using `React useReducer` and `context` api

## Note
Required react version `16.8.0-alpha.0`

## Install
`npm install react-hooks-state`

## Example
```
import React from "react";
import ReactDOM from "react-dom";
import { createStore } from "react-hooks-state";

const INCREMENT = "INCREMENT";

type State = {
  count: number;
};

type Action = {
  type: string;
};

const reducer = (state: State, action: Action) => {
  console.log(state, action);
  switch (action.type) {
    case INCREMENT:
      return {
        ...state,
        count: state.count + 1
      };
    default:
      return state;
  }
};

const { useStore, Provider } = createStore(reducer, {
  count: 0
});

const App: React.SFC = () => {
  const { state, dispatch } = useStore();
  return (
    <div>
      <h2>Welcome to React app</h2>
      <p>Value increased: {state.count}</p>
      <button onClick={() => dispatch({ type: INCREMENT })}>Increment +</button>
    </div>
  );
};

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

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