You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the connected user to select a reaction on a message
9
+
:::caution
10
+
If you're moving from older versions to `11.0.0` then make sure to read ["Reactions 11.0.0"](../../release-guides/reactions-v11.mdx) release guide to help you transition to the new implementation.
The Stream Chat API provides built-in support for adding reactions to messages. The component library provides three default components to enable reaction selection and display:
a minimal list of the reactions added to a message
15
+
-[`ReactionSelector`](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Reactions/ReactionSelector.tsx) - allows the connected user to select a reaction on a message
16
+
-[`ReactionsList`](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Reactions/ReactionsList.tsx) - displays the reactions added to a message
17
+
-[`SimpleReactionsList`](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Reactions/SimpleReactionsList.tsx) - displays a minimal list of the reactions added to a message
20
18
21
19
## Basic Usage
22
20
23
-
By default, the `ReactionSelector` and `ReactionsList` components are included within `MessageSimple`. To render reaction UI within a
24
-
custom [Message UI](./message-ui.mdx) component, import both components (or `SimpleReactionsList` for a lightweight view) and render
25
-
conditionally.
21
+
By default, the `ReactionSelector` and `ReactionsList` components are included within `MessageSimple`. To render reaction UI within a custom [Message UI](./message-ui.mdx) component, import both components (or `SimpleReactionsList` for a lightweight view) and render conditionally.
26
22
27
23
```jsx
28
24
constCustomMessage= () => {
@@ -55,19 +51,14 @@ Be default, the `ReactionSelector` component provides the following reaction opt
55
51
-`haha`
56
52
-`wow`
57
53
-`sad`
58
-
-`angry`
54
+
-`angry` - removed in `11.0.0`
59
55
60
-
The `defaultMinimalEmojis` data set that populates the default reaction options can be found in the
61
-
[emojiData](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Channel/emojiData.ts) file in the
62
-
component library.
56
+
The `defaultMinimalEmojis` data set that populates the default reaction options can be found in the <GHComponentLinkas="code"text='emojiData'branch="v10.17.0"path='/Channel/emojiData.ts'/> file in the component library.
63
57
64
-
To override the default selection set, provide your own array of `MinimalEmoji` type objects and pass into the `reactionOptions`
65
-
prop on the `ReactionSelector` component. You can also override the default [handleReaction](./components/contexts/message-context.mdx#handlereaction)
66
-
function by adding the `handleReaction` prop.
58
+
To override the default selection set, provide your own array of `MinimalEmoji` type objects and pass into the `reactionOptions` prop on the `ReactionSelector` component. You can also override the default [`handleReaction`](../contexts/message-context.mdx#handlereaction) function by adding the `handleReaction` prop.
67
59
68
60
:::caution
69
-
If custom `reactionOptions` are supplied to the `ReactionSelector` component, then the same data set needs to be delivered to the
70
-
`ReactionsList` component so the display for processed reactions has the same emoji objects.
61
+
If custom `reactionOptions` are supplied to the `ReactionSelector` component, then the same data set needs to be delivered to the `ReactionsList` component so the display for processed reactions has the same emoji objects.
71
62
:::
72
63
73
64
```jsx
@@ -105,8 +96,7 @@ const CustomMessage = () => {
105
96
</Chat>;
106
97
```
107
98
108
-
To completely override the `ReactionSelector` and `ReactionsList` components in `MessageSimple`, pass your own custom components as props
109
-
to the [`Channel`](./components/core-components/channel.mdx).
99
+
To completely override the `ReactionSelector` and `ReactionsList` components in `MessageSimple`, pass your own custom components as props to the [`Channel`](../core-components/channel.mdx).
Additional props to be passed to the [NimbleEmoji](https://github.com/missive/emoji-mart/blob/master/src/components/emoji/nimble-emoji.js) component from `emoji-mart`.
126
+
Additional props to be passed to the [`NimbleEmoji`](https://github.com/missive/emoji-mart/blob/v3.0.1/src/components/emoji/nimble-emoji.js) component from `emoji-mart`.
137
127
138
128
| Type |
139
129
| ------ |
@@ -159,9 +149,9 @@ If true, shows the user's avatar with the reaction.
159
149
160
150
Function that adds/removes a reaction on a message (overrides the function stored in `MessageContext`).
@@ -205,9 +196,9 @@ If true, adds a CSS class that reverses the horizontal positioning of the select
205
196
206
197
## ReactionsList Props
207
198
208
-
### additionalEmojiProps
199
+
### additionalEmojiProps (removed in `11.0.0`)
209
200
210
-
Additional props to be passed to the [NimbleEmoji](https://github.com/missive/emoji-mart/blob/master/src/components/emoji/nimble-emoji.js) component from `emoji-mart`.
201
+
Additional props to be passed to the [`NimbleEmoji`](https://github.com/missive/emoji-mart/blob/v3.0.1/src/components/emoji/nimble-emoji.js) component from `emoji-mart`.
211
202
212
203
| Type |
213
204
| ------ |
@@ -217,9 +208,9 @@ Additional props to be passed to the [NimbleEmoji](https://github.com/missive/em
217
208
218
209
Custom on click handler for an individual reaction in the list (overrides the function stored in `MessageContext`).
@@ -263,9 +255,9 @@ If true, adds a CSS class that reverses the horizontal positioning of the select
263
255
264
256
## SimpleReactionsList Props
265
257
266
-
### additionalEmojiProps
258
+
### additionalEmojiProps (removed in `11.0.0`)
267
259
268
-
Additional props to be passed to the [NimbleEmoji](https://github.com/missive/emoji-mart/blob/master/src/components/emoji/nimble-emoji.js) component from `emoji-mart`.
260
+
Additional props to be passed to the [`NimbleEmoji`](https://github.com/missive/emoji-mart/blob/v3.0.1/src/components/emoji/nimble-emoji.js) component from `emoji-mart`.
269
261
270
262
| Type |
271
263
| ------ |
@@ -275,9 +267,9 @@ Additional props to be passed to the [NimbleEmoji](https://github.com/missive/em
275
267
276
268
Function that adds/removes a reaction on a message (overrides the function stored in `MessageContext`).
If you're moving from older versions to `11.0.0` then make sure to read ["Reactions 11.0.0"](../../release-guides/reactions-v11.mdx) release guide to help you transition to the new implementation.
12
+
:::
13
+
10
14
In this example, we will demonstrate how to override the library's default reaction set, which can be found stored as the
variable. We will replace the default set with up and down arrows, simulating an up/down voting feature.
13
17
14
18
### Choose Your Reactions
15
19
16
20
Under the hood, our `ReactionSelector`, `ReactionsList`, and `SimpleReactionsList` components render individual emoji objects
17
-
using the [`NimbleEmoji`](https://github.com/missive/emoji-mart/blob/master/src/components/emoji/nimble-emoji.js) component
18
-
from [emoji-mart](https://www.npmjs.com/package/emoji-mart). Therefore, the object type of our custom reactions needs to
21
+
using the [`NimbleEmoji`](https://github.com/missive/emoji-mart/blob/v3.0.1/src/components/emoji/nimble-emoji.js) component
22
+
from [`emoji-mart`](https://www.npmjs.com/package/emoji-mart). Therefore, the object type of our custom reactions needs to
19
23
conform to `NimbleEmoji` props.
20
24
21
25
`NimbleEmoji` accepts an `emoji` prop, which pertains to the object mapping of your custom reaction. The `emoji` prop has
@@ -107,15 +111,12 @@ const customReactions = [
107
111
```
108
112
109
113
:::caution
110
-
If custom `reactionOptions` are supplied to the selector component, then the same data set needs to be delivered to the
111
-
list component so the display for processed reactions has the same emoji objects.
114
+
If custom `reactionOptions` are supplied to the selector component, then the same data set needs to be delivered to the list component so the display for processed reactions has the same emoji objects.
112
115
:::
113
116
114
117
### The Final Code
115
118
116
-
Putting all the pieces together and building upon the [custom message](./message-ui.mdx#how-it-fits-together)
117
-
in the General Customization section, we are left with the following code for our [Message UI](../../components/message-components/message-ui.mdx)
118
-
component:
119
+
Putting all the pieces together and building upon the [custom message](./message-ui.mdx#how-it-fits-together) in the General Customization section, we are left with the following code for our [Message UI](../../components/message-components/message-ui.mdx) component:
0 commit comments