Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 292 Bytes

createState.md

File metadata and controls

20 lines (14 loc) · 292 Bytes

createState()

Create a state container.

Usage

import {createState} from 'libreact/lib/shim';

const State = createState({
  cnt: 1,
});

<State>{(state, setState) =>
  <button onClick={() => setState({cnt: state.cnt + 1})}>
    Clicks: {state.cnt}
  </button>
}</State>