# use-states-react

> react use states

Latest version **1.0.3** (published 2021-06-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install use-states-react
pnpm add use-states-react
yarn add use-states-react
bun add use-states-react
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-06-29 |
| First published | 2021-06-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | majid darvish |
| Maintainers | majiddarvish |
| Keywords | npm, react |

## Links

- npm: https://www.npmjs.com/package/use-states-react
- Repository: https://github.com/majidux/useStates
- Homepage: https://github.com/majidux/useStates#readme
- Issues: https://github.com/majidux/useStates/issues
- npm.io page: https://npm.io/package/use-states-react

## 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.3 (latest) — 2021-06-29
- 1.0.1 — 2021-06-29
- 1.0.0 — 2021-06-29

## README

# useStates

A custom hook based on useReducer and inspired by strategy design pattern for having multiple states


###### With npm:
```javascript
npm install --save use-states-react
```

###### With yarn:
```javascript
yarn add use-states-react
```


This is how you are going to use it : =>
```javascript
import { useStates } from "use-states-react";

const initialState = {
  name: "",
};

const Example = () => {
  const [state, setState] = useStates<any>(initialState);
  const { name } = state;
  const onChange = ({ target: { name, value } }) => {
    setState(
      {
        [name]: value,
      },
      () => console.log("Callback function")
    );
  };
  return (
    <>
      <input name="name" type="text" value={name} onChange={onChange} />
    </>
  );
};
```

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