0.0.34 • Published 3 years ago

use-connect-render v0.0.34

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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

3 years ago

0.0.34

3 years ago

0.0.32

3 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.24

4 years ago

0.0.25

4 years ago

0.0.26

4 years ago

0.0.27

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.23

4 years ago

0.0.2-1.4

4 years ago

0.0.19

4 years ago

0.0.2-1.3

4 years ago

0.0.2-1.2

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago