0.0.34 • Published 2 years ago
use-connect-render v0.0.34
import { useConnectRender } from 'use-connect-render'
Example 1:
function CompA() {
const { push } = useConnectRender('my-counter', { c: 0, started : false });
return (
<button onClick={()=> {
push('c', prev => prev + 1);
push('started', true)
}}>
Click me
</button>
);
}
function CompB() {
const { listen } = useConnectRender('my-counter', { c: 0, started : false });
const [counter, started] = listen('c','started');
return (
<div>
started : {started}
my count: {counter}
</div>
);
}
Example 2:
function CompA() {
const { push, getCurrent } = useConnectRender('my-counter', { c: 0 });
const count = useCallback(()=>{
const curr = getCurrent('c')[0];
push('c', curr + 1);
},[push, getCurrent]);
return (
<button onClick={count}>
Click me
</button>
);
}
function CompB() {
const { listen } = useConnectRender('my-counter', { c: 0 });
const [counter] = listen('c');
return (
<div>
my count: {counter}
</div>
);
}
0.0.33
2 years ago
0.0.34
2 years ago
0.0.32
2 years ago
0.0.30
2 years ago
0.0.31
2 years ago
0.0.28
2 years ago
0.0.29
2 years ago
0.0.24
3 years ago
0.0.25
3 years ago
0.0.26
3 years ago
0.0.27
3 years ago
0.0.20
3 years ago
0.0.21
3 years ago
0.0.22
3 years ago
0.0.23
3 years ago
0.0.2-1.4
3 years ago
0.0.19
3 years ago
0.0.2-1.3
3 years ago
0.0.2-1.2
3 years ago
0.0.18
3 years ago
0.0.17
3 years ago
0.0.16
3 years ago
0.0.15
3 years ago
0.0.10
3 years ago
0.0.11
3 years ago
0.0.12
3 years ago
0.0.13
3 years ago
0.0.14
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.7
3 years ago
0.0.5
3 years ago
0.0.6
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago