Goal
By the end of this guide you will have a chat interface where users can open a thread panel from any message, view the parent message with its reply count, browse threaded replies, and send new replies — all using v7 compound components and a state-based approach (no custom events needed).Prerequisites
- Completed the Integration Guide guide
- A running
CometChatProvidersetup with valid credentials - An existing chat screen using
CometChatMessageListandCometChatMessageComposer
Components Used
Step 1: Thread State Management
Store thethreadedMessage in state. When set, the thread panel renders. When cleared, it closes. This mirrors the pattern used in the sample app’s CometChatThreadPanel component.
File: ChatWithThreads.tsx
Step 2: Wire the Thread Trigger
Use theonThreadRepliesClick callback on CometChatMessageList to capture when a user clicks “Reply in Thread.” This sets the threaded message and opens the panel — no events required.
File: ChatWithThreads.tsx
Step 3: Build the Thread Panel
WhenthreadedMessage is set, render a side panel composing CometChatThreadHeader + CometChatMessageList (with parentMessageId) + CometChatMessageComposer (with parentMessageId, layout="compact", and enableRichTextEditor). The onClose callback clears the state to dismiss the panel.
File: ChatWithThreads.tsx
Step 4: Handle Parent Deleted
Use theonParentDeleted prop on CometChatThreadHeader to automatically close the thread panel when the parent message is deleted by another user or a moderation action.
File: ChatWithThreads.tsx
Complete Example
File: App.tsxNext Steps
- Thread Header — customize the thread header appearance
- Message List — configure message list rendering and options
- CometChatProvider — learn about provider configuration