Skip to main content

Common Patterns

These 8 patterns apply across all components. You do not need to look them up per-component:

Changes Within v7

Most of this page maps v6 to v7. These props existed in an earlier v7 release and were removed by a later one, so they affect you only if you are upgrading from one v7 version to another.
maxAttachments and maxFileSize were dropped in the 7.1.0 multi-attachment rewrite. TypeScript flags both as unknown props once you upgrade, but in plain JavaScript they are silently ignored — any cap you set simply stops applying, with no error. If your app is not typed, search for both before upgrading past 7.0.3.

CometChatConversations

Modified Props

Removed Props

New Props


CometChatMessageList

Modified Props

Removed Props

textFormatters was removed in 7.0.0 and the prop is back in 7.2.0. On 7.0.x–7.1.x it is unavailable and formatting must go through a plugin. Most v6 formatter classes carry over — see Porting a v6 formatter for what changes.

Porting a v6 formatter

The rule: in v7 a formatter works on text, never on the message. A string goes in, a string comes out. Composer-side formatters still get live-input access — the composer assigns inputElementReference, calls initializeComposerTracking(), fans keystrokes to onKeyUp()/onKeyDown(), and provides getCaretPosition()/setCaretPosition() — but only when enableRichTextEditor is set on the composer. What no longer reaches a formatter is the message object and the logged-in user, so every v6 member carrying that context is gone — along with the v6 hooks the kit used to call. Text Formatters is the reference for the v7 class: every member, who calls it, and what happens if you override it. This section covers only what changes when you bring a v6 class to it. Three outcomes, in the order you will meet them:
Compile errors
id is the only abstract member. A v6 subclass fails with TS2515: … does not implement inherited abstract member id until you add one:
Ids must be unique: the kit merges formatters into a map keyed by id, so two formatters sharing one id leave only the last, and reusing a built-in id (markdown-formatter, mentions-formatter, url-formatter) replaces that built-in. Plain JavaScript runs without an id, but every id-less formatter collapses onto the same key — declare one. getFormattedText() changed signature to (inputText?: string) => string. Two v6 shapes no longer type-check, both reported as TS2416:
  • returning undefined for empty input — return "" instead;
  • the two-parameter form getFormattedText(text, params) — v7 passes one argument, so a second parameter is never populated and reading it throws.
Where your transform has to live
v7 calls format(), whose default stores state and delegates to getFormattedText() and then to customLogicToFormatText(). Whether your v6 transform still runs depends on where you put it:
Members v7 removed
Calling one of these is a compile error in TypeScript (TS2339) and a TypeError in JavaScript. Reading one of the fields gives undefined, which throws as soon as you dereference it. Helpers: setStyle() · getStyle() · setClasses() · setCssClassMapping() · setId() · getId() · setMessage() · getMessage() · setLoggedInUser() · getLoggedInUser() · setComposerConfig() · getComposerConfig() · setMessageBubbleAlignment() · getMessageBubbleAlignment() · setCaretPositionAndRange() · addAtCaretPosition() · getPrecedingText() · checkPreviousCharacterUsingRange() · debounce() · cleanup() · stopTracking() · getKeyUpCallBack() · getKeyDownCallBack() Fields: messageObject · loggedInUser · user · group · composerId · messageBubbleAlignment · classes · cssClassMapping · textStyle · timeoutID Caret fields with a v7 replacement: currentCaretPosition and currentRange are gone, but caret access is not — use getCaretPosition() and setCaretPosition(). Apply styling with CSS against your own class names rather than setStyle/setClasses.
A throwing formatter is dropped, not surfaced. Only errors thrown from your own code or your constructor reach you directly. Anything thrown inside the display pipeline — format(), getFormattedText(), customLogicToFormatText() — is caught by the kit: text bubbles log console.warn("CometChatTextBubble: Error applying text formatter") and skip that formatter, while conversation subtitles, reply and edit previews, saved messages and search results swallow it with no message at all. Either way your formatting silently disappears rather than crashing the UI, so check the console first when a ported formatter renders nothing.
Hooks v7 no longer calls
Nothing surfaces these: your method stays on the class, nothing throws, and it is simply never invoked. This is the category to audit by hand. Some names appear in both lists — calling one of them is an error, overriding it is silent.
Add override to every method you believe the kit calls. TypeScript then reports TS4113: This member cannot have an 'override' modifier because it is not declared in the base class for each hook v7 no longer has, which turns this whole silent category into compile errors. Enabling noImplicitOverride in your tsconfig.json applies it to the whole class.
Attaching data at send time
v6’s formatMessageForSending() let a formatter stamp the outgoing message — tags, metadata — just before it went out. v7 has no formatter hook for this: nothing hands a formatter the message. The composer’s onSendButtonClick does not help either, because it fires after the SDK call with the confirmed message. Move the logic to the composer’s sendTextMessageOverride, which is called instead of the kit’s own send, so you build and send the message yourself:
Send it with CometChatUIKit.sendTextMessage(), not CometChat.sendMessage(). The override replaces the composer’s own send, including the optimistic insert into the message list. The UI Kit helper emits ui:message/sent at each stage, so your message appears immediately and then flips to sent. Call the SDK directly instead and the message is delivered but never shows up in the sender’s list until the conversation is reloaded.
Live input is now yours to drive
v6’s base onKeyUp() watched for trackCharacter, then called debouncedFormatTextOnKeyUp() for you. v7’s base onKeyUp() only forwards to the callback set by setKeyUpCallBack(), and formatText() runs only when the composer enters rich-text edit mode. v7 never reformats the live input on keystrokes by itself. A v6 formatter that relied on that inherited behaviour compiles, and then does nothing as you type. Call formatText() from your own onKeyUp() override (or from the callback you register) to restore it. Do not do both — registering your own onKeyUp via setKeyUpCallBack() while also overriding onKeyUp() and calling super.onKeyUp() recurses until the stack overflows. Set your tracking state explicitly too: on the v7 base class trackCharacter starts as '' and regexPatterns as [], so call setTrackingCharacter() and setRegexPatterns() in your constructor rather than relying on an inherited default.
None of this runs unless the composer has enableRichTextEditor. The composer binds formatters to its editor only when the rich-text editor is active, so without that prop inputElementReference stays null and no keystroke ever reaches your formatter. There is no error — live formatting simply never happens. Display formatting is unaffected.

New Props


CometChatMessageComposer

Renamed Props

New Props


CometChatMessageHeader

Modified Props

Removed Props

New Props


CometChatThreadHeader

Removed Props

New Props


CometChatUsers

Removed Props


CometChatGroups

Removed Props

New Props


CometChatGroupMembers

Modified Props

Removed Props

New Props


CometChatIncomingCall

Removed Props

New Props


CometChatOngoingCall

New Props


CometChatMessageBubble

Renamed Props

Modified Props

Removed Props

New Props


CometChatContextMenu

Renamed Props

Modified Props


CometChatConfirmDialog

All string/callback props moved to compound sub-components: New root-level props: isOpen, onClose, closeOnOutsideClick, variant. The compound sub-components are CometChatConfirmDialog.Root, .Icon (optional leading icon, new in v7), .Content, and .Actions.

CometChatActionSheet

All props moved to compound pattern: New root-level props: isOpen, onClose, layoutMode, title.

CometChatCheckbox

Renamed Props


CometChatChangeScope

Renamed Props

Modified Props


CometChatDate

Renamed Props

New Props


CometChatReactions

Renamed Props

Modified Props


CometChatReactionList

Renamed Props


CometChatFullScreenViewer

Renamed Props

Removed Props

New Props


CometChatImageBubble → CometChatImagesBubble

In v7, the image bubble is renamed CometChatImagesBubble and is self-extracting: pass the SDK message and the bubble derives its own attachments, caption, and alignment (and renders multiple images in a grid). The pre-extracted data props from v6 are gone.

Removed Props

New / Current Props

The other media bubbles likewise default to their multi-attachment v7 components: CometChatVideoBubble → CometChatVideosBubble, CometChatFileBubble → CometChatFilesBubble, and CometChatAudioBubble → CometChatAudiosBubble (attached audio files) or CometChatVoiceNoteBubble (recorded voice notes). The singular CometChat*Bubble components still ship and can be used standalone — only the default routing changed. This self-extracting pattern applies to all message bubbles in v7 (CometChatTextBubble, CometChatPollBubble, CometChatStickerBubble, CometChatCallBubble, and the action/collaborative bubbles too): each takes the SDK message and derives its own data. See Message Bubble.

CometChatSearchBar

Modified Props

New Props


CometChatButton

Renamed Props

Modified Props

New Props


Next Steps

Migration Overview

Architecture changes and step-by-step checklist

Components Overview

Browse all v7 components