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 ChannelList rows.
  • 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

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>;
};

Parameters

channel

TypeRequiredDescription
ChannelYesChannel whose message composer draft state is read.

Returns

TypeDescription
DraftMessage | undefinedDraft message payload for channel preview.