<Value>
Allows you to keep a state of an arbitrary value.
Usage
import {Value} from 'libreact/lib/Value';
<Value>{({value, set}) =>
<input value={value} onChange={(e) => set(e.target.value)} />;
}</Value>
Props
Signature
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';
@withValue
class MyComp extends Component {
}
Specify different prop name
@withValue('foobar')
class MyComp extends Component {
}
or merge the the whole object into props
@withValue('')
class MyComp extends Component {
}