From f221dd1a09ff0750cc795a03764faf99fee164ea Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Wed, 18 Dec 2024 10:30:05 -0800 Subject: [PATCH 1/2] Update some docstrings --- packages/react/src/context/participant-context.ts | 6 +++++- packages/react/src/hooks/useParticipantTracks.ts | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/react/src/context/participant-context.ts b/packages/react/src/context/participant-context.ts index 425f5653f..744b3efe3 100644 --- a/packages/react/src/context/participant-context.ts +++ b/packages/react/src/context/participant-context.ts @@ -2,7 +2,11 @@ import type { Participant } from 'livekit-client'; import * as React from 'react'; import { useMaybeTrackRefContext } from './track-reference-context'; -/** @public */ +/** + * Provides a {@link Participant} to the component tree. + * + * @public + */ export const ParticipantContext = React.createContext(undefined); /** diff --git a/packages/react/src/hooks/useParticipantTracks.ts b/packages/react/src/hooks/useParticipantTracks.ts index e79266e4f..c66cba81f 100644 --- a/packages/react/src/hooks/useParticipantTracks.ts +++ b/packages/react/src/hooks/useParticipantTracks.ts @@ -6,8 +6,11 @@ import type { Track } from 'livekit-client'; import { useMaybeParticipantContext, useRoomContext } from '../context'; /** - * `useParticipantTracks` is a custom React that allows you to get tracks of a specific participant only, by specifiying the participant's identity. - * If the participant identity is not passed the hook will try to get the participant from a participant context. + * Hook to acquire the tracks of a specific participant only. By default the hook will look in the component tree for a {@link ParticipantContext}. + * To specify a different participant, pass their `identity`. + * + * You may also filter the returned tracks by `Source` (e.g. `Camera`, `Microphone`, `ScreenShare`, etc). + * * @public */ export function useParticipantTracks( From 6af569ca62aefc69e34a0b56fea3dc0de685dab3 Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Wed, 18 Dec 2024 10:38:52 -0800 Subject: [PATCH 2/2] better --- packages/react/src/context/participant-context.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/react/src/context/participant-context.ts b/packages/react/src/context/participant-context.ts index 744b3efe3..06812e4c5 100644 --- a/packages/react/src/context/participant-context.ts +++ b/packages/react/src/context/participant-context.ts @@ -3,7 +3,20 @@ import * as React from 'react'; import { useMaybeTrackRefContext } from './track-reference-context'; /** - * Provides a {@link Participant} to the component tree. + * Provides a `Participant` to the component tree. Used by {@link useParticipantAttributes}, {@link useParticipantTracks}, and {@link useParticipantInfo}. + * + * This context is provided automatically by the {@link ParticipantLoop} and {@link ParticipantTile} components. + * + * You may also provide one explicitly with {@link ParticipantContext.Provider}. + * + * @example + * ```tsx + * + * {children} + * + * ``` + * + * Hooks to read the `Participant` from the context include {@link useParticipantContext}, {@link useMaybeParticipantContext}, and {@link useEnsureParticipant}. * * @public */