1.0.2 • Published 4 years ago
telereact v1.0.2
telereact
The most elegant state manager for React apps
Install
npm install telereact
Documentation
Basic usage
import { Provider, connect } from 'telereact';
const App = () => (
<Provider initialState={{ a: 1, b: { c: 3, d: 0 } }}>
<Router />
</Provider>
);
// ...
const Container = ({ setState, a, b }) => (
<div>
<button onClick={() => setState({ a: a + 1 })} />
<p>a: {a}</p>
<button
onClick={() =>
setState(
{ b: { c: b.c + 1 } }, // This setState call will not change b.d
{ deepMerge: true }, // because the meta object has deepMerge: true
)
}
/>
<p>b.c: {b.c}</p>
<p>b.d: {b.d}</p>
</div>
);
export default connect('a, b')(Container);
License
MIT © MiLeung