This is beta documentation for Stream Chat React SDK v14. For the latest stable version, see the latest version (v13) .

Reactions

The SDK includes built-in message reactions. The main reaction surfaces are:

Best Practices

  • Keep reaction options concise so the selector stays scannable.
  • Memoize custom sortReactions comparators.
  • Use SimpleReactionsList in dense or compact layouts.
  • Customize the selector and detail dialog together so their emoji sets stay aligned.
  • Prefer reaction_groups over legacy reaction_counts.

Sorting Reactions

By default, reactions are sorted chronologically by the first time a reaction type was used. You can change this with sortReactions on MessageList or VirtualizedMessageList.

import { Channel, MessageInput, MessageList } from "stream-chat-react";

const sortByReactionCount = (a, b) => b.reactionCount - a.reactionCount;

const App = () => (
  <Channel>
    <MessageList sortReactions={sortByReactionCount} />
    <MessageInput />
  </Channel>
);

Pass reactionDetailsSort to MessageList or VirtualizedMessageList to control the order of users in the default reaction-detail dialog.

Customization

Use WithComponents to replace the default reaction surfaces for a Channel subtree:

import {
  Channel,
  ChannelHeader,
  MessageInput,
  MessageList,
  MessageReactionsDetail,
  ReactionSelector,
  ReactionsList,
  Thread,
  Window,
  WithComponents,
} from "stream-chat-react";

const CustomReactionSelector = (props) => <ReactionSelector {...props} />;
const CustomReactionsList = (props) => (
  <ReactionsList {...props} visualStyle="segmented" />
);
const CustomMessageReactionsDetail = (props) => (
  <MessageReactionsDetail {...props} />
);

const App = () => (
  <WithComponents
    overrides={{
      MessageReactionsDetail: CustomMessageReactionsDetail,
      ReactionSelector: CustomReactionSelector,
      ReactionsList: CustomReactionsList,
    }}
  >
    <Channel>
      <Window>
        <ChannelHeader />
        <MessageList />
        <MessageInput />
      </Window>
      <Thread />
    </Channel>
  </WithComponents>
);

ReactionSelector Props

PropDescriptionType
handleReactionFunction that adds or removes a reaction. Overrides the value from MessageContext.(reactionType: string, event: React.BaseSyntheticEvent) => Promise<void>
own_reactionsOwn reactions used to highlight the selected state.ReactionResponse[]

ReactionsList Props

PropDescriptionType
flipHorizontalPositionControls whether the horizontal position is flipped relative to the current message alignment. Defaults to false.boolean
handleFetchReactionsCustom loader for reaction details.MessageContextValue["handleFetchReactions"]
own_reactionsOwn reactions used to highlight the current user's reactions.ReactionResponse[]
reaction_groupsGrouped reaction summary used to build the list. Prefer this over legacy reaction_counts.Record<string, ReactionGroupResponse>
reactionDetailsSortSort options used when loading reaction details for MessageReactionsDetail.MessageContextValue["reactionDetailsSort"]
reactionsRaw reaction objects used to build the grouped list.ReactionResponse[]
reverseDisplays reactions in reverse order. Defaults to false.boolean
sortReactionDetailsLegacy comparator used to sort reaction-detail users.ReactionDetailsComparator
sortReactionsComparator used to order grouped reactions.ReactionsComparator
verticalPositionControls whether the list renders above or below the message bubble. Defaults to 'top'.'top' | 'bottom' | null
visualStyleControls whether the list renders in clustered or segmented mode. Defaults to 'clustered'.'clustered' | 'segmented' | null

SimpleReactionsList Props

SimpleReactionsList accepts the same reaction data props as ReactionsList and additionally supports handleReaction.

MessageReactionsDetail Props

PropDescriptionType
handleFetchReactionsCustom loader for fetching reaction details.MessageContextValue["handleFetchReactions"]
onSelectedReactionTypeChangeCallback used when the selected reaction type changes.(reactionType: ReactionType | null) => void
reactionDetailsSortSort options used to fetch reaction details.MessageContextValue["reactionDetailsSort"]
reactionsGrouped reaction summary used to build the detail UI.ReactionSummary[]
selectedReactionTypeCurrently selected reaction type in the detail view.ReactionType | null
sortSort options for the fetched reaction details.ReactionSort
sortReactionDetailsLegacy comparator used to sort reaction-detail users after fetching.ReactionDetailsComparator
totalReactionCountTotal number of reactions shown in the detail dialog.number