ParticipantLoop
function ParticipantLoop(__namedParameters): Element;Defined in: packages/react/src/components/participant/ParticipantLoop.tsx:48
The ParticipantLoop component loops over an array of participants to create a context for every participant. This component takes exactly one child component as a template. By providing your own template as a child you have
Parameters
| Parameter | Type |
|---|---|
__namedParameters | ParticipantLoopProps |
Returns
Element
Example
// Basic — render a name for every participant.
const participants = useParticipants();
<ParticipantLoop participants={participants}>
<ParticipantName />
</ParticipantLoop>;
// Advanced — build a roster with participant context per row.
function Roster() {
const participants = useParticipants();
return (
<VoiceRoom agent={agent}>
<ParticipantLoop participants={participants}>
<ParticipantContextIfNeeded><ParticipantName /></ParticipantContextIfNeeded>
</ParticipantLoop>
</VoiceRoom>
);
}