Rcf is a react component, it uses a clear and simple way to manage your state: Do not use "this.state" and "this.setState", just use store, which is a plain object.
Put your component in Rcf and Rcf allows it to get store by "this.props.*" and set store by "this.props.set".When you call 'set' function,it will change the value of store, then all of the Rcf component using this store will be re rendered.
npm install rcf
const A = props => <div>
A:
{props.a}
<button onClick={() => {
props.set({
a: props.a - 1,
});
}}>
click
</button>
</div>
const B = props => <div>
B:
{props.a}
</div>
const store = {a: 1};
ReactDOM.render(<div>
<Rcf store={store}>
<A />
<B />
</Rcf>
<Rcf store={store}>
<B />
</Rcf>
</div>,
mountDom);
http://flutejs.github.io/rcf/examples/example-a.html
name | type | description |
---|---|---|
store | object | plain object |
tag | string | object | default: 'div', the root element
When the number of children is greater than 1, set root element to tag |
set | string | default: 'set', the name of set function.
If you don't want to call "this.props.set", you can set "set" to what you want, then you can use "this.props.*"
|