Valora
API Reference@valora-ai/reactindexFunctions

ParticipantContextIfNeeded

function ParticipantContextIfNeeded(__namedParameters): Element;

Defined in: packages/react/src/components/participant/ParticipantContextIfNeeded.tsx:39

The ParticipantContextIfNeeded component only creates a ParticipantContext if there is no ParticipantContext already.

Parameters

ParameterType
__namedParametersParticipantContextIfNeededProps

Returns

Element

Example

// Basic — add participant context only when one is missing.
<ParticipantContextIfNeeded participant={participant}>
  <ParticipantName />
</ParticipantContextIfNeeded>

// Advanced — keep participant children working inside and outside loops.
function RosterNames() {
  const participants = useParticipants();

  return (
    <VoiceRoom agent={agent}>
      <ParticipantLoop participants={participants}>
        <ParticipantContextIfNeeded><ParticipantName /></ParticipantContextIfNeeded>
      </ParticipantLoop>
    </VoiceRoom>
  );
}

On this page

Valora is local-first

No API key, no server — everything in this doc runs on-device.

Star on GitHub