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