@react-mock/state

Inject React component state declaratively.

Usage no npm install needed!

<script type="module">
  import reactMockState from 'https://cdn.skypack.dev/@react-mock/state';
</script>

README

Component state

Inject React component state declaratively.

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

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.