# use-mapped-state

> A React hook for mapping state on each state change

Latest version **0.0.1** (published 2019-08-29) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-08-29 |
| First published | 2019-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Elad Bezalel |
| Maintainers | eladbezalel |

## Links

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

## Recent versions

- 0.0.1 (latest) — 2019-08-29

## README

<div align="center">
  <h1>
    <br/>
    🗺️
    <br />
    use-mapped-state    
  </h1>  
  <br />
  <pre>yarn add <a href="https://www.npmjs.com/package/use-mapped-state">use-mapped-state</a></pre>
  <br />

A React hook for mapping state on each state change
<br />
<br />
<br />

</div>

## Usage

```tsx
import useMappedState from 'use-mapped-state';

const Comp = () => {
  const [state, setState, [value1, yoValue]] = useMappedState(
    'initialValue',
    value => value + 1,
    value => 'Yo' + value
  );

  return (
    <div>
      <span>{state}</span>
      <span>{value1}</span>
      <span>{yoValue}</span>
      <button onClick={() => setState('Cool')} />
    </div>
  );
};

export default Comp;
```

### Typings

The cool thing about this hook is that you get a typed return value of your map functions

```tsx
const [
  num, // number
  setNum, // Dispatch..
  [
    value1, // number
    value2, // string
    value3, // object
  ],
] = useMappedState(1, value => value + 1, value => 'Yo' + value, value => ({ value }));
```

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