react-state-render-prop

A component for introducing state through render props. Especially useful for controlling arrays of controlled components. Written in TypeScript.

Usage no npm install needed!

<script type="module">
  import reactStateRenderProp from 'https://cdn.skypack.dev/react-state-render-prop';
</script>

README

React State Render Prop

A component for introducing state through render props. Especially useful for controlling arrays of controlled components. Written in TypeScript.

Installation

yarn add react-state-render-prop

or

npm i react-state-render-prop

Usage

import { State } from 'react-state-render-prop';

const Example = () => {
  return (
    <div>
      <State initialState={0}>
        {(state, setState) => (
          <button onClick={() => setState(state => state + 1)}>{state}</button>
        )}
      </State>
    </div>
  );
};