How can I limit to 2 participants only?

31 Views Asked by At

I tried a code that limits up to 2 participants only. However, I tested it by joining up to three participants. The third one still appears even though I set a perimeter where the meeting has 2 participants. The third one is unable to join.

I've tried to make it = or > but still doesn't work

`

const [participantCount, setParticipantCount] = useState(0);

...

useEffect(() => {
(joined === "JOINED") {setParticipantCount(participants.size);}}, [participants, joined]);

const joinMeeting = () => {

if (participantCount >= 2) {   
alert("The meeting is full. Only 2 participants are allowed.");  
return;} 
 setJoined("JOINING"); join(); };

return(
...
<button
onClick={joinMeeting}                     
className={btnStyle}                     
disabled={participants >= 2 ? true : false}>Join</button>
...

)

0

There are 0 best solutions below