useIsSpeaking
function useIsSpeaking(participant?): boolean;Defined in: packages/react/src/hooks/track/useIsSpeaking.ts:37
The useIsSpeaking hook returns a boolean that indicates if the participant is speaking or not.
Parameters
| Parameter | Type |
|---|---|
participant? | unknown |
Returns
boolean
Example
// Basic — read whether a participant is speaking.
const isSpeaking = useIsSpeaking(participant);
// Advanced — highlight active speakers in a participant list.
function SpeakerRow({ participant }: { participant: Participant }) {
const isSpeaking = useIsSpeaking(participant);
return <span data-speaking={isSpeaking}>{isSpeaking ? "Speaking" : "Quiet"}</span>;
}
function SpeakerRows() {
const participants = useParticipants();
return participants.map((participant, index) => (
<SpeakerRow key={index} participant={participant} />
));
}
function SpeakerList() {
return <VoiceRoom agent={agent}><SpeakerRows /></VoiceRoom>;
}