import { useChannelPreviewDraftMessage } from "stream-chat-react-native";
const DraftBadge = ({ channel }: { channel: Channel }) => {
const draftMessage = useChannelPreviewDraftMessage({ channel });
if (!draftMessage) return null;
return <Text>{`Draft: ${draftMessage.text ?? "Attachment"}`}</Text>;
};This is beta documentation for Stream Chat React Native SDK v9. For the latest stable version, see the latest version (v8)
.
useChannelPreviewDraftMessage
Returns the current draft message for a channel preview when the composer has pending text and attachments.
Best Practices
- Use this hook to signal draft state in
ChannelListrows. - Treat the return value as optional and render fallback UI when absent.
- Do not mutate the returned draft object.
- Keep draft indicators lightweight to preserve list performance.
- Pair this hook with custom preview text formatting for clarity.
Usage
Parameters
channel
| Type | Required | Description |
|---|---|---|
Channel | Yes | Channel whose message composer draft state is read. |
Returns
| Type | Description |
|---|---|
DraftMessage | undefined | Draft message payload for channel preview. |