lei.ocopio
lei.ocopio

Reputation: 1

How can I limit to 2 participants only?

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>
...

)

Upvotes: 0

Views: 52

Answers (0)

Related Questions