Chat UIKit React v3
Chat UIKit React
Chat UIKit
React
Version 3

Reactions

Copy link

In a group channel with multiple users, reactions become especially useful as a social interaction tool for uninterrupted engagement while chatting. Sendbird UIKit also supports the reactions feature in the framework. UIKit reactions, which are based on the Sendbird Chat SDK's reactions feature, provide a default emoji set to suit diverse messaging needs. You can also customize the reactions UI just like the global themes.

Note: Currently, UIKit reactions are only available for group channels. This feature isn't supported in open channels, Supergroup channels, and custom message types.


Implementation guide for reactions

Copy link

Once a client app is connected with Sendbird server, the predefined emoji list can be accessed. A combination of the emoji list and reaction information contained within each message completes the look of the reactions UI.

In order to implement reactions, two settings need to be checked beforehand:

  • The application settings for reactions
  • The emojis registered in the application

Components

Copy link

There are two ways in which reactions can be expressed by users:

  • Hover over a message and click on the Add reaction button that appears to reveal a full Emoji list
  • Click on an existing reaction in the Emoji reaction box to add a user count to the emoji reaction

Add reaction button

Copy link

The Add reaction button can be accessed either by hovering over a message without a reaction, or finding the button at the end of the Emoji reaction box below the message. Clicking this button fires an onClick event that then calls the Emoji list.

Emoji list

Copy link

The Emoji list displays all emojis registered within an application. Emoji reactions already added to a message by the current user are indicated with a highlighted background color.

Emoji reaction box

Copy link

When a text or file message contains reaction data, this data is displayed below the message in the form of emoji reactions. The count of users who have the added emoji reaction to the message is also marked right next to each emoji reaction. Clicking an emoji in the Emoji reaction box adds or removes the reacted user count.

Tapping on the Add reaction button in the box will reveal the full Emoji list to add different emoji reactions.

Reacted user list

Copy link

Hovering over an emoji in the Emoji reaction box displays a list of users who have reacted to the message with the same emoji.


Customize the reactions UI

Copy link

You can customize the UI for reactions including emojis by using three context variables: emojiContainer, nicknamesMap, and emojiAllMap. You can retrieve them from ChannelProvider through useChannelContext().

import { ChannelProvider, useChannelContext } from '@sendbird/uikit-react/Channel/context';

const CustomChannelUI = () => {
    const {
        emojiContainer,
        nicknamesMap,
        emojiAllMap,
    } = useChannelContext();
    return (
        <div>
        {/* implement your custom channel ui */}
        </div>
    );
};

const CustomChannel = () => {
    return (
        <ChannelProvider>
            <CustomChannelUI />
        </ChannelProvider>
    );
};