import { useContext } from 'react';
import { ThreadContext } from 'stream-chat-react-native';
const value = useContext(ThreadContext);
ThreadContext
ThreadContext
is provided by Channel
component. If you are not familiar with React Context API, please read about it on React docs.
Basic Usage
ThreadContext
can be consumed by any of the child component of Channel
component as following:
Alternatively, you can also use useThreadContext
hook provided by library to consume ThreadContext.
import { useThreadContext } from 'stream-chat-react-native';
const value = useThreadContext();
Value
allowThreadMessagesInChannel
Display the Show thread message in channel button inside the thread MessageInput.
Type | Default |
---|---|
boolean | true |
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 |
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
A message object that when set indicates a thread is open.
When used with the Thread
component this will display the thread.
When used with the standard MessageList
component this will prevent any singleton components in the OverlayProvider
form getting out of sync.
thread
should be set 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>
| |