# use-combined-state

> React hooks like useState but can set partial state

Latest version **0.1.2** (published 2019-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-combined-state
pnpm add use-combined-state
yarn add use-combined-state
bun add use-combined-state
```

## 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.1.2 |
| Published | 2019-03-02 |
| First published | 2019-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Chen XI |
| Maintainers | xc1427 |
| Keywords | react, hooks, useState |

## Links

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

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

- 0.1.2 (latest) — 2019-03-02
- 0.1.1 — 2019-03-01
- 0.1.0 — 2019-03-01

## README

# use-combined-state

## Motivation
Restore how `setState` is used before React without hooks. Hooks is awesome. However `setState` should be passed _full state_ as value returned in Redux reducer. You may also find grouping state under a single "namespace" improve readability.

## Usage

```js
import useCombinedState from 'use-combined-state';

// ...

const [ state, setState ] = useCombinedState({ visible: true, data: { titi: 'toto' } });


// set partial state to update, preserve `data` field.
setState({
  visible: false,
})

setState((prevState) => ({
  visible: !prevState.visible, // can pass a function which sets partial state
}))

<SomeComponent visible={state.visible}>
```

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