ThreadContext

ThreadContext is provided by Channel. If you are not familiar with the React Context API, see the React docs.

Best Practices

  • Use useThreadContext for consistent access and typings.
  • Manage thread navigation via openThread/closeThread rather than manual state.
  • Use threadHasMore and threadLoadingMore to control pagination.
  • Keep thread UI logic separate from channel message lists.
  • Avoid heavy computations in thread context consumers.

Basic Usage

Consume ThreadContext in any child of Channel:

import { useContext } from "react";
import { ThreadContext } from "stream-chat-react-native";

const value = useContext(ThreadContext);

Alternatively, use the useThreadContext hook.

import { useThreadContext } from "stream-chat-react-native";

const value = useThreadContext();

Values

Value Description Type
allowThreadMessagesInChannel Show the Show thread message in channel button in thread MessageComposer. Defaults to true. boolean
closeThread Unsets the thread and thread messages in the Channel state. function
loadMoreThread Loads more messages for the thread. Returns a promise. () => Promise<void>
loadMoreRecentThread Loads more recent messages for the thread. Returns a promise. (opts: { limit?: number }) => Promise<void> | undefined
onAlsoSentToChannelHeaderPress Called when the user presses the "Also sent to channel" header on Message. (payload: AlsoSentToChannelHeaderPressPayload) => void | undefined
openThread Sets the thread and thread messages in the Channel state. function
parentMessagePreventPress Boolean to enable/disable parent message press. Defaults to true. boolean
reloadThread Reloads the thread and thread messages. function
setThreadLoadingMore A function which can be used to set the thread loading more state. function
thread Can be a LocalMessage or ThreadType. Setting it indicates a thread is open. Both types are interchangeable. With Thread, this displays the thread. With the standard MessageList, it keeps singleton components in OverlayProvider in sync. object
threadHasMore Boolean flag for thread messages pagination. boolean
threadInstance Instance of Thread used to read more data or pass to onThreadSelect. Thread
threadLoadingMore Boolean flag for thread messages loading more state. boolean | undefined
threadLoadingMoreRecent Boolean flag for thread messages loading more recent state. boolean | undefined
threadMessages A list of formatted messages objects. Array<object>