I'm using React + ASP.NET application and using VideoSDK API for video-meeting.
const meetingAPI = useMeeting({
onMeetingJoined: () => {
meetinAPI.muteMic();
meetinAPI.disableWebcam();
if (isCreator) {
let intervalId = setInterval(async () => {
console.log(
"minutes",
minutes +
gameHash.ActivePlayers.length
);
if (
minutes + gameHash.ActivePlayers.length >= asset.VideoTime - 10 * ActivePlayers.length
) {
setVideoMinutesRunoutModalOpen(true);
}
}, 1000 * 60);
setTimerId(intervalId);
}
setIsMeetingJoined(true);
},
})
isCreator and gameHash is component state. When it changed, I expect value in onMeetingJoined change too. But it's always the initial value. How can I solve this?
I've tried to use useCallback or useMemo. But it's not working.
I've experienced same issue before. And their support team was so helpful. You can use state ref for that.
As you can see, stateRef is reference for your state. onMeetingJoined is a third party callback so your state change is not reflected. And this is the solution.