Package Exports
- react-state
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-state) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-state
localized state in React render functions.
npm install react-state --save
class Counter{
render(){
return <State initial={0}>{
(val, set) =>
<div onClick={() => set(val + 1)}>
clicked {val} times
</div>
}</State>;
}
}
React.render(<Counter/>, el); // just works.
// there's also a functional form to mask the reacty bits
class Counter{
render(){
return state({initial: 0}, (val, set) =>
<div onClick={() => set(val + 1)}>
clicked {val} times
</div>);
}
}
// that said, do remember that it's the reacty nature of
// that 'instance' that preserves it across renders, etc.
props
- initial
- onChange: function
children
: function
made this repo to use / test shallow rendering and whatnot. wish me luck.
(tests curently PASS.)