How to update state of reactjs in realtime from an polkadotjs rpc api?

118 views Asked by At
  const unsubHeads = await data.rpc.chain.subscribeNewHeads((lastHeader) => {
            console.log(`: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
           
        });

I'm using polkadot js rpc api for updating my reactjs (showing las block number in realtime), everything is working fine, the block number is also showing dynamically in above code, but I'm unable to set the new state inside the loop.

1

There are 1 answers

0
Dan Forbes On