Thread
Message threading is a feature in the UIKit that allows users to reply to each other's messages in a channel. When using the thread mode of message threading, users can reply to a message and start a new conversation in a separate thread. To display the thread view, use the Thread
module.
Note : Threads is currently a beta feature that's still undergoing testing and development for improvement. Some inadvertent issues may arise while implementing this module. If you encounter any bugs or if you have any helpful feedback, contact our support team.
Usage
To start using the Thread
module, implement the following code:
List of properties
The following table lists the properties of the Thread
module.
Properties
Required | Type | Description |
---|---|---|
channelUrl | string | Specifies the URL of the group channel. (Default: |
message | UserMessage or FileMessage | Specifies the message in the group channel that the thread belongs to. |
Optional | Type | Description |
---|---|---|
onHeaderActionClick | function | Specifies the prop to execute custom operations when the close button in the |
onMoveToParentMessage | function | Specifies the prop to execute custom operations when the |
disableUserProfile | boolean | Determines whether to display the user profile preview dialog when selecting the user avatar. If set to |
renderUserProfile | ReactElement | Renders a customized user profile preview dialog when selecting the user avatar. (Default: |
onUserProfileMessage | function | Specifies the prop to receive callback when a user has successfully created a 1-to-1 chat from clicking on a user profile view. (Default: |
renderHeader | ReactElement | Renders a customized thread header component. (Default: |
renderParentMessageInfo | ReactElement | Renders a customized parent message info component. (Default: |
renderMessage | ReactElement | Renders a customized reply message in the thread list component. (Default: |
renderMessageInput | ReactElement | Renders a customized message input component. (Default: |
renderCustomSeparator | ReactElement | Renders a customized date separator in the thread list component. (Default: |
renderParentMessageInfoPlaceholder | ReactElement | Renders a customized placeholder for a parent message info status in the thread view. It passes |
renderThreadListPlaceHolder | ReactElement | Renders a customized placeholder for a thread list status in the thread view. It passes |
Context
To store and handle data that are used to build a thread UI, Sendbird UIKit provides two context objects: ThreadProvider
and useThreadContext
. The ThreadProvider
is a context provider that manages all the logic and data used in the message thread view. The useThreadContext
is a context hook that allows access to the provider's data.
ThreadProvider
The ThreadProvider
contains input props and internal data that handle all the operations in the module. The provider stores data from Chat SDK in real-time and exports them to the UI components. The following code shows how to start using ThreadProvider
.
List of properties
The following table lists the properties of ThreadProvider
.
Properties
Required | Type | Description |
---|---|---|
channelUrl | string | Specifies the URL of the group channel. (Default: |
message | UserMessage or FileMessage | Specifies the message in the group channel that the thread belongs to. |
Optional | Type | Description |
---|---|---|
onHeaderActionClick | function | Specifies the prop to execute custom operations when the close button in the |
onMoveToParentMessage | function | Specifies the prop to execute custom operations when the |
disableUserProfile | boolean | Determines whether to display the user profile preview dialog when selecting the user avatar. If set to |
renderUserProfile | ReactElement | Renders a customized user profile preview dialog when selecting the user avatar. (Default: |
onUserProfileMessage | function | Specifies the prop to receive callback when a user has successfully created a 1-to-1 chat from clicking on a user profile view. (Default: |
Set current channel for customization
You should set the current channel with onHeaderActionClick
callback when you customize.
useThreadContext
The useThreadContext
hook exports the data in the provider to the UI components to create a functional view of message threads. Every UI component of any layer or level can get access to the data using the context hooks as long as they're inside the provider.
The following code shows how to start using useThreadContext
.
See the code below on how to create the custom UI component using useThreadContext
.
List of properties
The following table lists the properties of useThreadContext
.
Property name | Type | Description |
---|---|---|
currentChannel | Specifies the current group channel. | |
channelState | string/enum | Specifies the state of the |
parentMessage | UserMessage or FileMessage | Specifies the parent message of the thread. |
parentMessageState | string/enum | Specifies the state of |
allThreadedMessages | array of objects | Specifies a list of all threaded messages. |
threadListState | string/enum | Specifies the state of |
hasMorePrev | boolean | Determines whether to retrieve previous replies at the top of the thread list. |
hasMoreNext | boolean | Determines whether to retrieve more replies in the thread list. |
emojiContainer | EmojiContainer | Specifies a set of all emojis that can be used and customized in the thread. |
isMuted | boolean | Determines whether the channel that the thread exists in is muted or not. |
isChannelFrozen | boolean | Determines whether the channel that the thread exists in is frozen or not. |
UI components
The UI components in the Thread
module are the following: ThreadUI
, ThreadHeader
, ParentMessageInfo
, ThreadList
, ThreadListItem
, and ThreadMessageInput
. They're the default set of UI components that compose the thread view.
ThreadUI
The ThreadUI
is the component that displays the basic screen of the module. It contains placeholders for error and loading statuses and renders various components shown in the screen. The following code shows how to implement ThreadUI
.
List of properties
The following table lists the properties of ThreadUI
.
Property name | Type | Description |
---|---|---|
renderHeader | ReactElement | Renders a customized thread header component. (Default: |
renderParentMessageInfo | ReactElement | Renders a customized parent message info component. (Default: |
renderMessage | ReactElement | Renders a customized reply message in the thread list component. (Default: |
renderMessageInput | ReactElement | Renders a customized message input component. (Default: |
renderCustomSeparator | ReactElement | Renders a customized date separator in the thread list component. (Default: |
renderParentMessageInfoPlaceholder | ReactElement | Renders a customized placeholder for a parent message info status in the thread view. It passes |
renderThreadListPlaceHolder | ReactElement | Renders a customized placeholder for a thread list status in the thread view. It passes |
See the code below on how to customize ThreadUI
.
ThreadHeader
The ThreadHeader
is the header component of the ThreadUI
that displays the thread title, channel name, and a close button that closes the thread view.
The following code shows how to implement ThreadHeader
.
Properties
Required | Type | Description |
---|---|---|
channelName | string | Specifies the name of the channel that the thread exits in. |
Optional | Type | Description |
---|---|---|
renderActionIcon | ReactElement | Renders a customized close button icon that closes the thread view. |
onActionIconClick | function | Specifies the prop to execute custom operations when the top-right icon in the thread header component is clicked. (Default: |
onChannelNameClick | function | Specifies the prop to execute custom operations when the channel name in the thread header component is clicked. (Default: |
ParentMessageInfo
The ParentMessageInfo
component shows the parent message in the thread view located right below ThreadHeader
. See the code below on how to implement ParentMessageInfo
.
ThreadList
The ThreadList
component shows the number of replies in the thread and a list of all replies to that message are shown in a chronological order. The list shows both user and file messages and replies sent by the current user are differentiated from those sent by other members in different colors. The following code shows how to implement ThreadList
.
List of properties
The following table lists the properties of ThreadList
.
Required | Type | Description |
---|---|---|
allThreadedMessages | array of objects | Specifies a list of all threaded messages. |
Optional | Type | Description |
---|---|---|
renderMessage | ReactElement | Renders a customized reply message in the thread list component. (Default: |
renderCustomSeparator | ReactElement | Renders a customized date separator in the thread list component. (Default: |
See the code below on how to customize ThreadList
.
ThreadListItem
The ThreadListItem
displays each reply item, user and file message, in the ThreadList
component.
List of properties
The following table lists the properties of ThreadListItem
.
Required | Type | Description |
---|---|---|
message | UserMessage or FileMessage | Specifies the message in the group channel that the thread belongs to. |
Optional | Type | Description |
---|---|---|
chainTop | boolean | Determines whether to group the message with previously sent messages. (Default: |
chainBottom | boolean | Determines whether to group the message with other messages that were sent afterward. (Default: |
hasSeparator | boolean | Determines whether to render a customized date separator view in the message list component that separates the messages by date. (Default: |
renderCustomSeparator | ReactElement | Renders a customized date separator in the thread list component. (Default: |
ThreadMessageInput
The ThreadMessageInput
is the component where users can reply to a parent message in the thread by sending a user or file message such as an image, video, or a document file. See the code below on how to implement ThreadMessageInput
.