Display Attendees Count - React Native
This guide explains the process of displaying the number of attendees in realtime.
note
Before proceeding with this guide, ensure that all attendees join the meeting with the mode set to VIEWER
.
Step 1:
Start by obtaining all the participants
using the useMeeting
hook.
import { useMeeting } from "@videosdk.live/react-native-sdk";
function AttendessCount() {
const { participants } = useMeeting();
return <></>;
}
Step 2:
Subsequently, filter out those who have joined as VIEWER
and display the count.
import { useMeeting } from "@videosdk.live/react-native-sdk";
import { useMemo } from "react";
import { Text } from "react-native";
function AttendessCount() {
const { participants } = useMeeting();
const attendeesCount = useMemo(() => {
const attendees = [...participants.values()].filter((participant) => {
return participant.mode == "VIEWER";
});
return attendees.length || 0;
}, [participants]);
return (
<>
<Text>Number of Attendess: {attendeesCount}</Text>
</>
);
}
API Reference
The API references for all the methods utilized in this guide are provided below.
Got a Question? Ask us on discord