useSortedParticipants
function useSortedParticipants(participants): unknown[];Defined in: packages/react/src/hooks/participant/useSortedParticipants.ts:30
The useSortedParticipants hook returns the participants sorted by importance.
Parameters
| Parameter | Type |
|---|---|
participants | unknown[] |
Returns
unknown[]
Example
// Basic — sort an existing participant list.
const sortedParticipants = useSortedParticipants(participants);
// Advanced — render important participants first.
function SortedRoster() {
return (
<VoiceRoom agent={agent}>
<SortedParticipantList />
<RoomAudioRenderer />
</VoiceRoom>
);
}
function SortedParticipantList() {
const participants = useParticipants();
const sortedParticipants = useSortedParticipants(participants);
return <ParticipantLoop participants={sortedParticipants}><ParticipantName /></ParticipantLoop>;
}