Open jonasgroendahl opened 3 years ago
For reference:
setRoom(currentRoom => {
if (currentRoom && currentRoom.localParticipant.state === 'connected') {
currentRoom.localParticipant.tracks.forEach(function(trackPublication) {
trackPublication.track.stop();
});
currentRoom.disconnect();
return null;
} else {
return currentRoom;
}
});
Something to do with this conditional render that just destroys the room variable before the clean-up function can do "things":
const handleLogout = useCallback(event => {
setToken(null);
}, []);
let render;
if (token) {
render = (
<Room roomName={roomName} token={token} handleLogout={handleLogout} />
);
} else {
render = (
<Lobby
username={username}
roomName={roomName}
handleUsernameChange={handleUsernameChange}
handleRoomNameChange={handleRoomNameChange}
handleSubmit={handleSubmit}
/>
);
}
If I'm not calling handleLogout, the clean-up function will run OK
Hey @jonasgroendahl, I'm testing this in my browsers (Chrome and Firefox on Mac) and I'm not seeing a problem with stopping the tracks. Can you confirm which browser/OS you are seeing this in?
Also, what do you mean when you say "If I'm not calling handleLogout
, the clean-up function will run OK"? How are you causing the clean-up function to run without removing the token from the state?
Is there anything else you've changed about the project before coming across this issue?
hello everyone,
am I the only one having a problem with the clean-up function for the useEffect in the Room component? for me the room is just "null" once the clean-up function fires and doesn't get to call disconnect() and stop all the tracks for the room. this leaves the camera icon on at the top and you're still connected despite not being on the video page anymore