react-peer
react-peer copied to clipboard
state not updating when using useReceivePeerState
Hi,
Thanks for the library! I am running into issues with useReceivePeerState and React w/ hooks. It seems that the state variable returned from useReceivePeerState does not update when there is new data on the channel. However, refreshing the page causes the latest data to be loaded. My receiver code is pretty much identical to your sample:
function Recv() {
const urlParams = new URLSearchParams(window.location.search);
const brokerId = urlParams.get("broker")!;
const [state, isConnected, error] = useReceivePeerState<string>(brokerId);
return (
<h1>{state}</h1>
);
}
export default Recv;
So, this code only works when manually refreshing the page. It does cause a re-render when new data is sent from the peer.
Hey mate - thanks for raising this!
Would you be interested in sending over a fix? 😄