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

ValueDescriptionType
allowThreadMessagesInChannelShow the Show thread message in channel button in thread MessageComposer. Defaults to true.boolean
closeThreadUnsets the thread and thread messages in the Channel state.function
loadMoreThreadLoads more messages for the thread. Returns a promise.() => Promise<void>
loadMoreRecentThreadLoads more recent messages for the thread. Returns a promise.(opts: { limit?: number }) => Promise<void> | undefined
onAlsoSentToChannelHeaderPressCalled when the user presses the "Also sent to channel" header on Message.(payload: AlsoSentToChannelHeaderPressPayload) => void | undefined
openThreadSets the thread and thread messages in the Channel state.function
parentMessagePreventPressBoolean to enable/disable parent message press. Defaults to true.boolean
reloadThreadReloads the thread and thread messages.function
setThreadLoadingMoreA function which can be used to set the thread loading more state.function
threadCan 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
threadHasMoreBoolean flag for thread messages pagination.boolean
threadInstanceInstance of Thread used to read more data or pass to onThreadSelect.Thread
threadLoadingMoreBoolean flag for thread messages loading more state.boolean | undefined
threadLodingMoreRecentBoolean flag for thread messages loading more recent state.boolean | undefined
threadMessagesA list of formatted messages objects.Array<object>