useParticipantContext
function useParticipantContext(): unknown;Defined in: packages/react/src/hooks/participant/useParticipantContext.ts:21
Ensures that a participant is provided via context. If not inside a ParticipantContext, an error is thrown.
Returns
unknown
Example
function ContextualParticipantName() {
const participant = useParticipantContext();
const { identity, name } = useParticipantInfo({ participant });
return <span>{name ?? identity}</span>;
}
<ParticipantContext.Provider value={{ identity: "local-user", name: "You" }}><ContextualParticipantName /></ParticipantContext.Provider>;