Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/threepointone/react-state

localized react state component
https://github.com/threepointone/react-state

Last synced: about 1 month ago
JSON representation

localized react state component

Lists

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.)