https://github.com/threepointone/react-state
localized react state component
https://github.com/threepointone/react-state
Last synced: 2 months ago
JSON representation
localized react state component
- Host: GitHub
- URL: https://github.com/threepointone/react-state
- Owner: threepointone
- Created: 2015-06-14T12:05:34.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-16T09:33:02.000Z (almost 10 years ago)
- Last Synced: 2025-03-02T02:11:29.171Z (3 months ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 34
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
react-state
---localized state in React render functions.
`npm install react-state --save`
```js
class Counter{
render(){
return {
(val, set) =>
set(val + 1)}>
clicked {val} times
};
}
}React.render(, el); // just works.
// there's also a functional form to mask the reacty bits
class Counter{
render(){
return state({initial: 0}, (val, set) =>
set(val + 1)}>);
clicked {val} times
}
}// 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[based on this thread](https://discuss.reactjs.org/t/children-as-a-function-render-callbacks/626)
made this repo to use / test shallow rendering and whatnot. wish me luck.
(tests curently PASS.)