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
Copy file name to clipboardExpand all lines: SAMPLES.md
+37-38Lines changed: 37 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Find out more about Sendbird UIKit for React at [UIKit for React doc](https://se
23
23
24
24
## UIKit components and ways to customize
25
25
26
-
These samples are here to help you better understand UIKit for React by going over the core components and ways to customize. On each core component sample, there is an attached CodeSandbox link in which you can see the sample codes and alter them to see how the changes are rendered.
26
+
These samples are here to help you better understand UIKit for React by going over the core components and ways to customize. On each core component sample, there is an attached [StackBlitz](https://stackblitz.com/) link in which you can see the sample codes and alter them to see how the changes are rendered.
27
27
28
28
<br />
29
29
@@ -43,7 +43,7 @@ The minimum requirements for UIKit for React are:
43
43
44
44
### Implement Chat with App component
45
45
46
-
The `App` component is a collection of all UIKit components you need to implement chat. This is included in all core component samples, so be sure to set your own APP_ID, USER_ID, and NICKNAME in `const.js` in each to customize your sample. On the [CodeSandbox](https://codesandbox.io/s/1-1-using-sendbird-app-9l4d4b) link, you will see that the props of the `App` component refer to use the values of the correspondings of `const.js` for initialization.
46
+
The `App` component is a collection of all UIKit components you need to implement chat. This is included in all core component samples, so be sure to set your own APP_ID, USER_ID, and NICKNAME in `const.js` in each to customize your sample. On the [StackBlitz](https://stackblitz.com/edit/sendbird-react-uikit-base-app) link, you will see that the props of the `App` component refer to use the values of the correspondings of `const.js` for initialization.
47
47
48
48
Try setting your own by downloading the Sendbird sample.
49
49
@@ -55,7 +55,7 @@ import SendbirdApp from '@sendbird/uikit-react/App';
55
55
56
56
Here is a list of the essential components that you need to import before you start customizing chat. Note that the names of the components are changed as shown in the code below.
57
57
58
-
Try [importing components on CodeSandbox](https://codesandbox.io/s/1-2-customization-basic-format-9skqq3).
58
+
Try [importing components on StackBlitz](https://stackblitz.com/edit/sendbird-react-uikit-customized-app).
Each CodeSandbox sample has `App.js` and `CustomizedApp.js` which operate based on the imported `const.js`. CodeSandbox is a code editor that provides an instant live preview. The preview has two buttons placed at the top center. If you click the left button, you will see unaltered `App.js`. If you click the right button, you will see the customized component from `CustomizedApp.js`, and any changes you make on them applied and rendered on the live preview.
69
+
Each StackBlitz sample has `App.js` and `CustomizedApp.js` which operate based on the imported `const.js`. StackBlitz is a code editor that provides an instant live preview. The preview has two buttons placed at the top center. If you click the left button, you will see unaltered `App.js`. If you click the right button, you will see the customized component from `CustomizedApp.js`, and any changes you make on them applied and rendered on the live preview.
70
70
71
-
If you would like to get a deeper understanding of how CodeSandbox works, refer to **CustomizedMessageItems**, **CustomizedHeader**, **CustomizedMessageInput**, and **CustomizedChannelPreviewItem** which you can find on corresponding CodeSandbox samples.
71
+
If you would like to get a deeper understanding of how StackBlitz works, refer to **CustomizedMessageItems**, **CustomizedHeader**, **CustomizedMessageInput**, and **CustomizedChannelPreviewItem** which you can find on corresponding StackBlitz samples.
72
72
73
73
<br />
74
74
@@ -80,7 +80,7 @@ This section explains what you need to know before testing the sample app.
80
80
81
81
The **renderChatItem** is a `ReactElement` prop in the Channel component which you can use to customize `message` by setting a function. This prop provides three arguments: **message**, **onUpdateMessage**, and **onDeleteMessage**. The **message** represents an already sent or received message of an `BaseMessage` object; **onUpdateMessage** and **onDeleteMessage** are callback functions which you can implement with custom code for events related to the corresponding user actions.
82
82
83
-
Try your [message item on CodeSandbox](https://codesandbox.io/s/2-1-customizing-messageitem-q38cg5).
83
+
Try your [message item on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-message-item).
84
84
85
85
```javascript
86
86
<Channel
@@ -96,29 +96,29 @@ Try your [message item on CodeSandbox](https://codesandbox.io/s/2-1-customizing-
96
96
>
97
97
```
98
98
99
-
> Note: You can try making your own customized message item by using `<CustomizedMessageItem />` on the CodeSandbox sample.
99
+
> Note: You can try making your own customized message item by using `<CustomizedMessageItem />` on the StackBlitz sample.
100
100
101
101
### Message list params
102
102
103
103
The **queries.messageListParams** is an `instance` prop in the **channel** component which you can use to retrieve a list of messages by specifying the properties of `MessageListParams`.
104
104
105
-
Try your [message list params on CodeSandbox](https://codesandbox.io/s/2-2-customizing-messagelistparams-3ipi0g).
105
+
Try your [message list params on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-message-list-params).
106
106
107
-
> Note: On CodeSandbox’s preview, only the messages you sent will be displayed.
107
+
> Note: On StackBlitz preview, only the messages you sent will be displayed.
108
108
109
109
```javascript
110
110
// Pass arguments in JSON data input format to the query instance.
111
-
const[queries]=useState({
111
+
constqueries=useMemo(() =>({
112
112
// use object json type input, don't create sendbird query instance
The **onBeforeSendUserMessage**, **onBeforeSendFileMessage**, and **onBeforeUpdateUserMessage** are `callback function` props in the **channel** component. The first two execute additional operations for a user message and a file message respectively; the corresponding modified messages are returned through the **text** and the **file** arguments respectively. The **onBeforeUpdateUserMessage** executes additional operations for a user message before updating it.
129
129
130
-
Try your [message params on CodeSandbox](https://codesandbox.io/s/2-3-customizing-messageparams-606156)
130
+
Try your [message params on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-message-params)
131
131
132
-
> Note: On the CodeSandbox’s preview, you can send or update a message in highlight.
132
+
> Note: On the StackBlitz preview, you can send or update a message in highlight.
133
133
134
134
```javascript
135
135
<Channel
@@ -139,7 +139,7 @@ Try your [message params on CodeSandbox](https://codesandbox.io/s/2-3-customizin
139
139
>
140
140
```
141
141
142
-
In order to complete an operation you intend to carry out with each function, you should return `UserMessageParams`and `FileMessageParams` objects.
142
+
In order to complete an operation you intend to carry out with each function, you should return `UserMessageCreateParams`, `UserMessageUpdateParams`and `FileMessageCreateParams` objects.
Find out more about `UserMessageParams`and `FileMessageParams` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/interfaces/_sendbird_chat_message.UserMessageCreateParams.html).
152
+
Find out more about `UserMessageCreateParams`, `UserMessageUpdateParams`and `FileMessageCreateParams` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/modules/_sendbird_chat_message.html).
153
153
154
154
### Chat header
155
155
156
156
The **renderChatHeader** is a `ReactElement` prop in the **channel** component which you can use to customize the header of `channel` by setting a function. This prop provides two arguments: **channel** and **user**. The channel refers to a `GroupChannel` object which is a collection of properties necessary to render the current channel view. The **user** refers to a `User` object which represents the current user.
157
157
158
-
Try your [chat header on CodeSandbox](https://codesandbox.io/s/2-4-customizing-chatheader-mi5ijz)
158
+
Try your [chat header on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-chat-header)
159
159
160
160
```javascript
161
161
<Channel
@@ -165,13 +165,13 @@ Try your [chat header on CodeSandbox](https://codesandbox.io/s/2-4-customizing-c
165
165
>
166
166
```
167
167
168
-
> Note: You can try making your own customized chat header item by using `<CustomizedHeader />` on the CodeSandbox sample.
168
+
> Note: You can try making your own customized chat header item by using `<CustomizedHeader />` on the StackBlitz sample.
169
169
170
170
### Message input
171
171
172
172
The **renderMessageInput** is a `ReactElement` prop in the **Channel** component which allows you to customize the message input by setting a function. This prop provides three arguments: **channel**, **user**, and **disabled**. The **channel** refers to a `GroupChannel` object which is a collection of properties necessary to render the current channel view. The **user** refers to a `User` object which represents the current user. The **disabled** refers to whether to enable the message input box or not.
173
173
174
-
Try your [message input on CodeSandbox](https://codesandbox.io/s/2-5-customizing-messageinput-forked-or4lm8)
174
+
Try your [message input on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-message-input)
175
175
176
176
```javascript
177
177
<Channel
@@ -181,13 +181,13 @@ Try your [message input on CodeSandbox](https://codesandbox.io/s/2-5-customizing
181
181
>
182
182
```
183
183
184
-
> Note: You can try making your own customized message input item by using `<CustomizedMessageInput />` on the CodeSandbox sample.
184
+
> Note: You can try making your own customized message input item by using `<CustomizedMessageInput />` on the StackBlitz sample.
185
185
186
186
### Channel preview item
187
187
188
188
The **renderChannelPreview** is a `ReactElement` prop in the **ChannelList** component which allows you to customize channel preview by setting a function. This prop provides two arguments: **channel** and **onLeaveChannel**. The **channel** refers to a `GroupChannel` object which is a collection of properties necessary to render the current channel view. The **onLeaveChannel** has a callback function as an argument which can be implemented with custom code for events related to the corresponding user action.
189
189
190
-
Try your [channel preview item on CodeSandbox](https://codesandbox.io/s/3-1-customizing-channelpreviewitem-7c9xz6)
190
+
Try your [channel preview item on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-channel-preview)
The **queries.channelListQuery** is an `instance` prop in the **ChannelList** component which filters channels by using its options.
216
216
217
-
Try your [channel list query item on CodeSandbox](https://codesandbox.io/s/3-2-customizing-channellistquery-d0t2l8)
217
+
Try your [channel list query item on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-channel-list-queries)
218
218
219
-
> Note: On the CodeSandbox’s preview, the empty channels that you see means that the channels are successfully created and there are no messages sent by users.
219
+
> Note: On the StackBlitz’s preview, the empty channels that you see means that the channels are successfully created and there are no messages sent by users.
220
220
221
221
```javascript
222
222
// Pass arguments in JSON data input format to the query instance.
223
-
const[queries]=useState({
223
+
constqueries=useMemo(() =>({
224
224
channelListQuery: {
225
+
// Should be an instance of GroupChannelListQueryParams
Find out more about `ChannelListQuery` and `ApplicationUserListQuery` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/classes/_sendbird_chat_groupChannel.GroupChannelListQuery.html).
243
+
Find out more about `ChannelListQuery` and `ApplicationUserListQuery` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/modules/_sendbird_chat_groupChannel.html).
245
244
246
245
### Channel params
247
246
248
247
The **onBeforeCreateChannel** is a prop of the **ChannelList** component which can be implemented with custom code for events related to the corresponding user actions.
249
248
250
-
Try your [channel param on CodeSandbox](https://codesandbox.io/s/3-3-customizing-channelparams-vgcgtj)
249
+
Try your [channel param on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-channel-params)
251
250
252
251
> Note: you can create a channel using `GroupChannelParams`.
0 commit comments