# @react-mock/state

> Inject React component state declaratively

Latest version **0.1.8** (published 2019-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @react-mock/state
pnpm add @react-mock/state
yarn add @react-mock/state
bun add @react-mock/state
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.8 |
| Published | 2019-03-12 |
| First published | 2018-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 365 |
| Author | Ovidiu Cherecheș |
| Maintainers | skidding |

## Links

- npm: https://www.npmjs.com/package/@react-mock/state
- Repository: https://github.com/skidding/react-mock
- Homepage: https://github.com/skidding/react-mock#readme
- Issues: https://github.com/skidding/react-mock/issues
- npm.io page: https://npm.io/package/@react-mock/state

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.1.2

## Recent versions

- 0.1.8 (latest) — 2019-03-12
- 0.1.7 — 2018-10-16
- 0.1.6 — 2018-10-15
- 0.1.5 — 2018-10-12
- 0.1.4 — 2018-10-12
- 0.1.3 — 2018-09-29
- 0.1.2 — 2018-09-25
- 0.1.1 — 2018-09-21

## README

## Component state

Inject React component state declaratively.

> `StateMock` must be the direct parent of the stateful component for the state injection to work.

```js
import { StateMock } from '@react-mock/state';

render(
  <StateMock state={{ count: 5 }}>
    <Counter />
  </StateMock>
);
```

> **Warning:** StateMock delays ref calls. This means refs can get called _after_ componentDidMount, instead of before as you [might expect](https://stackoverflow.com/questions/44074747/componentdidmount-called-before-ref-callback).

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