lazorfuzz / liowebrtc

An event-based WebRTC library that makes it easy to embed real-time peer to peer communication into UI components.
MIT License
164 stars 10 forks source link

onReceivedPeerData Only Uses Initial State Value, Not Current State #28

Closed rachel-elas-ai closed 2 years ago

rachel-elas-ai commented 2 years ago

Somehow, the function passed to onReceivedPeerData only ever uses the initial value for a state variable, never its current state. Here's a bare minimum example: https://stackoverflow.com/questions/71447566/react-state-variables-not-updating-in-function

Note: I added an extra button that calls the same function inside the LioWebRTC wrapper, and the current state does print for that, so it seems like it's something to do with LioWebRTC itself. How is that even possible for it not to use the current state?