telereact
v1.0.2
Published
The most elegant state manager for React apps
Downloads
26
Maintainers
Readme
telereact
The most elegant state manager for React apps
Install
npm install telereactDocumentation
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
