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();

Value

allowThreadMessagesInChannel

Show the Show thread message in channel button in thread MessageInput.

TypeDefault
booleantrue

closeThread

Unsets the thread and thread messages in the Channel state.

Type
Function

loadMoreThread

Loads more messages for the thread. Returns a promise.

Type
() => Promise<void>

openThread

Sets the thread and thread messages in the Channel state.

Type
function

parentMessagePreventPress

Boolean to enable/disable parent message press.

TypeDefault
Booleantrue

reloadThread

Reloads the thread and thread messages.

Type
function

setThreadLoadingMore

A function which can be used to set the thread loading more state.

Type
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.

Set thread on all Channel components when a thread is open.

Type
object

threadHasMore

Boolean flag for thread messages pagination.

Type
boolean

threadLoadingMore

Boolean flag for thread messages loading more state.

Type
boolean

threadMessages

A list of formatted messages objects.

| Type | | --------------- | --- | | Array<object> | |