Fetching contributors…
Cannot retrieve contributors at this time
83 lines (52 sloc) 1.12 KB


Allows you to keep a state of an arbitrary value.


import {Value} from 'libreact/lib/Value';

<Value>{({value, set}) =>
  <input value={value} onChange={(e) => set(} />;



interface IValueProps {
  init?: any;

, where

  • init - optional, default value.

withValue() HOC

HOC that merges value prop into enhanced component's props.

import {withValue} from 'libreact/lib/Value';

const MyCompWithValue = withValue(MyComp);

You can overwrite the injected prop name

const MyCompWithValue = withValue(MyComp, 'foobar');

Or simply merge the whole object into your props

const MyCompWithValue = withValue(MyComp, '');

@withValue decorator

React stateful component decorator that adds value prop.

import {withValue} from 'libreact/lib/Value';

class MyComp extends Component {


Specify different prop name

class MyComp extends Component {


or merge the the whole object into props

class MyComp extends Component {