useEnsureParticipant
function useEnsureParticipant(participant?): unknown;Defined in: packages/react/src/hooks/participant/useEnsureParticipant.ts:31
Ensures that a participant is provided, either via context or explicitly as a parameter. If not inside a ParticipantContext and no participant is provided, an error is thrown.
Parameters
| Parameter | Type |
|---|---|
participant? | unknown |
Returns
unknown
Example
// Basic — require a participant from props or context.
const participant = useEnsureParticipant();
// Advanced — render participant-aware quality UI.
function ParticipantQuality({ participant }: { participant?: Participant }) {
const ensuredParticipant = useEnsureParticipant(participant);
const { quality } = useConnectionQualityIndicator({ participant: ensuredParticipant });
return (
<ParticipantContext participant={ensuredParticipant}>
<ConnectionQualityIndicator />
<span>{quality}</span>
</ParticipantContext>
);
}