MessagesContext

Best Practices

  • Use this context for message-level UI concerns, not global channel state.
  • Prefer the provided handlers (handleEdit, handleDelete, etc.) to keep behavior consistent.
  • Avoid heavy logic in handlers that can trigger list-wide re-renders.
  • Use removeMessage/updateMessage only for local UI state, not server-side mutations.
  • Keep messageActions and supportedReactions stable (memoized) for performance.

Values

ValueDescriptionType
additionalPressablePropsExtra props passed to the underlying Pressable used in message components like MessageContent.object
channelIdID of the current channel.string
customMessageSwipeActionCustom handler invoked when a message row swipe action is triggered. Use it to override the default swipe-to-reply behavior.function
deleteMessageDelete a message using the channel state updater.function
deleteReactionDelete a reaction from a message.function
disableTypingIndicatorDisable the typing indicator in MessageList. Defaults to false.boolean
dismissKeyboardOnMessageTouchDismiss the keyboard when the user touches a message in the list. Defaults to false.boolean
enableMessageGroupingByUserIf false, consecutive messages from the same user won't be grouped. Available in SDK version >= v3.9.0. Defaults to true.boolean
urlPreviewTypeThe type of URL preview to render. Defaults to 'full'.'compact' | 'full'
enableSwipeToReplyIf true, users can swipe the full MessageItemView row to reply to a message. Defaults to true.boolean
forceAlignMessagesForces all messages to align left or right. By default, received messages are left and sent messages are right. Defaults to false.'left' | 'right' | false
getMessageGroupStyleOverride how message groups are styled and grouped in MessageList.function
formatDateFormat function for dates in message status and deleted message components. Accepts a date parameter provided as a string, Date, or number (Unix Timestamp).function
handleBanCalled when the Ban User action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleCopyCalled when the Copy Message action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleDeleteCalled when the Delete Message action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleDeleteForMeCalled when the Delete Message for me action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleEditCalled when the Edit Message action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleFlagCalled when the Flag Message action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleMuteCalled when the Mute User action is triggered from the message actions list. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleMarkUnreadCalled when the Mark Unread action is triggered.function
handlePinMessageCalled when the Pin/Unpin Message action is triggered.function | null
handleQuotedReplyCalled when the Reply action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleReactionCalled when a reaction is selected in the message menu (add or remove). It does not override default behavior. See customize message actions. Accepts message and reactionType parameters.function
handleRetryCalled when the Retry action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleThreadReplyCalled when the Thread Reply action is triggered. It does not override default behavior. See customize message actions. Accepts a message parameter.function
handleBlockUserCalled when the Block User action is triggered.function
isMessageAIGeneratedReturns whether a message should be treated as AI-generated for message rendering.function
initialScrollToFirstUnreadMessageLoad the channel starting at the first unread message. Defaults to false.boolean
isAttachmentEqualReturns true if rendering nextAttachment would produce the same result as prevAttachment, otherwise false. Accepts prevAttachment and nextAttachment parameters.function
legacyImageViewerSwipeBehaviourEnable/disable legacy image viewer behavior. When true, the image viewer lets you swipe through all loaded images in the channel, adding JS thread work. Available in SDK version >= v3.9.0. Defaults to false.boolean
markdownRulesRules for simple-markdown.object
messageActionsAn array of actions, or a function returning an array, shown in the message menu. Accepts an actionInfo parameter containing the original actions and relevant message data. See customize message actions. Defaults to messageActions.array | function
messageContentOrderOrder for rendering message content. Defaults to ['quoted_reply', 'gallery', 'files', 'text', 'attachments'].array
quotedMessageQuoted message used by reply-related UI in the message list.LocalMessage | null
myMessageThemeTheme applied to the current user's messages. Memoize this object or pass a stable reference.object
messageSwipeToReplyHitSlopDefines the hitSlop area for the full-row swipe-to-reply gesture. Defaults to {left: screenWidth, right: screenWidth}.object { top: number, left: number, bottom: number, right: number }
messageTextNumberOfLinesNumber of lines for message text in the Message Overlay. Defaults to 5.number
onLongPressMessageCalled when a user long-presses a message. The default opens the message menu. Accepts a payload parameter ({ actionHandlers, message }).function
onPressInMessageCalled on touch start, before onPressMessage. Accepts a payload parameter ({ actionHandlers, message }).function
onPressMessageCalled when a user presses a message. The default handler behaves differently for reactions and attachments; handle those cases if you override it. Accepts a payload parameter ({ additionalInfo, actionHandlers, message }). additionalInfo provides extra data for certain emitters (for example, user details for textMention). Note: additionalInfo may change as more emitter use cases are added.function
reactionListPositionPosition of the reaction list in the message component. Defaults to 'top'.'top' | 'bottom'
removeMessageRemove a message from local state only (does not call channel.deleteMessage).(message) => void
retrySendMessageRetry sending a failed message.(message) => void
sendReactionSend a reaction for the target message.function
selectReactionFull override of the message reaction handler. It must return a function that accepts reactionType (string). Accepts a message parameter. See customize message actions.function | null
setEditingStateSet editing state for a message.(message) => void
setQuotedMessageStateSet quoted-reply state for a message.(message) => void
shouldShowUnreadUnderlayEnable/disable the unread underlay background in the message list. Defaults to true.boolean | undefined
supportedReactionsList of reactions users can add to messages. See customizing reactions. Defaults to reactionData.array
targetedMessageID of the highlighted message. Defaults to undefined and resets after the highlight timeout.string
updateMessageUpsert a message in local state. Does not call channel.sendMessage (used for optimistic updates).(message) => void
openPollCreationDialogCalled when the poll creation button is clicked in the attachment picker. Use it to override the default modal UI. If overridden, a payload is passed with sendMessage from MessageInputContext for use in CreatePoll.function
hasCreatePollControls whether the poll creation button is visible.boolean
FlatListFlatList component used by MessageList. Defaults to flat-list-mvcp.ComponentType
giphyVersionGiphy image version to render. See the Image Object keys for options. Defaults to 'fixed_height'.string

Examples

onPressMessage

<Channel
      onPressMessage={({ additionalInfo, defaultHandler, emitter }) => {

          if (emitter === 'textMention') {
            console.log(additionalInfo?.user);
            return;
          }

          if (emitter === 'urlPreview' || emitter === 'textLink') {
            console.log(additionalInfo?.url);
            return;
          }

          if (emitter === 'fileAttachment') {
            console.log(additionalInfo?.attachment);
            return;
          }

          defaultHandler?.();
      }}
    >