import { ChannelMediaListProvider } from "stream-chat-react-native";
<ChannelMediaListProvider channel={channel}>
{/* media list UI */}
</ChannelMediaListProvider>;ChannelMediaListContext
ChannelMediaListContext is provided by ChannelMediaListProvider. Mount the provider around your media-list UI to access the search source used to query and paginate its media attachments. If you are not familiar with the React Context API, see the React docs.
ChannelMediaListProvider takes the channel it operates on as a prop. In the channel-details flow, the MediaList component renders the provider and reads that channel from ChannelDetailsContext, so nested components don't need it via props.
Best Practices
- Render
ChannelMediaListProviderwith thechannelwhose media you want to list — inside the channel-details flow this comes fromChannelDetailsContext. - Use
searchSourcefor querying and paginating media; it is pre-configured to returnimageandvideoattachments, newest first. - Pass a custom
searchSourceonly when you need different filtering, sorting, or page size — otherwise rely on the default the provider creates. - Calling
useChannelMediaListContextoutside the provider throws — render your media-list UI as a child ofChannelMediaListProvider.
Basic Usage
Wrap your media-list UI in ChannelMediaListProvider:
Consume ChannelMediaListContext in any child of the provider:
import { useContext } from "react";
import { ChannelMediaListContext } from "stream-chat-react-native";
const { searchSource } = useContext(ChannelMediaListContext);Alternatively, use the useChannelMediaListContext hook to consume ChannelMediaListContext.
import { useChannelMediaListContext } from "stream-chat-react-native";
const { searchSource } = useChannelMediaListContext();Values
| Value | Description | Type |
|---|---|---|
searchSource * | A MessageSearchSource used to query and paginate the channel's media attachments. Pre-configured to return image and video attachments, sorted by created_at descending. | MessageSearchSource |