Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state not updating when using useReceivePeerState #13

Open
aroman opened this issue May 3, 2020 · 1 comment
Open

state not updating when using useReceivePeerState #13

aroman opened this issue May 3, 2020 · 1 comment

Comments

@aroman
Copy link

aroman commented May 3, 2020

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.

@itsdouges
Copy link
Owner

Hey mate - thanks for raising this!

Would you be interested in sending over a fix? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants