Skip to content

Commit c06361e

Browse files
authored
doc: Update samples and new sample links (#235)
1 parent 4591482 commit c06361e

File tree

1 file changed

+59
-51
lines changed

1 file changed

+59
-51
lines changed

SAMPLES.md

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Sendbird UIKit for React is a development kit with an user interface that enable
77

88
### More about Sendbird UIKit for React
99

10-
Find out more about Sendbird UIKit for React at [UIKit for React doc](https://sendbird.com/docs/uikit/v1/javascript/getting-started/about-uikit). If you need any help in resolving any issues or have questions, visit [our community](https://community.sendbird.com).
10+
Find out more about Sendbird UIKit for React at [UIKit for React doc](https://sendbird.com/docs/uikit/v3/react/overview). If you need any help in resolving any issues or have questions, visit [our community](https://community.sendbird.com).
1111

1212
<br />
1313

@@ -26,32 +26,31 @@ The minimum requirements for UIKit for React are:
2626

2727
- React 16.8.0+
2828
- React DOM 16.8.0+
29-
- Sendbird Chat SDK for JavaScript 3.0.115+
29+
- @sendbird/chat v4
3030
- css-vars-ponyfill 2.3.2
3131
- date-fns 2.16.1
3232

3333
### Implement Chat with App component
3434

35-
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-9xum5) link, you will see that the props of the `App` component refer to use the values of the correspondings of `const.js` for initialization.
35+
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.
3636

3737
Try setting your own by downloading the Sendbird sample.
3838

3939
```javascript
40-
import { App as SendbirdApp } from 'sendbird-uikit'
40+
import SendbirdApp from '@sendbird/uikit-react/App'
4141
```
4242

4343
### Import components to customize UIKit
4444

4545
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.
4646

47-
Try [importing components on CodeSandbox](https://codesandbox.io/s/1-2-customization-basic-format-q4e6c).
47+
Try [importing components on CodeSandbox](https://codesandbox.io/s/1-2-customization-basic-format-9skqq3).
4848

4949
```javascript
50-
import {
51-
Channel as SBConversation,
52-
ChannelList as SBChannelList,
53-
ChannelSettings as SBChannelSettings,
54-
} from 'sendbird-uikit'
50+
import SBConversation from '@sendbird/uikit-react/Channel';
51+
import SBChannelList from '@sendbird/uikit-react/ChannelList';
52+
import SBChannelSettings from '@sendbird/uikit-react/ChannelSettings';
53+
import withSendBird from '@sendbird/uikit-react/withSendbird';
5554
```
5655

5756
### Referring to CodeSandbox
@@ -70,7 +69,7 @@ This section explains what you need to know before testing the sample app.
7069

7170
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.
7271

73-
Try your [message item on CodeSandbox](https://codesandbox.io/s/2-1-customizing-messageitem-0nop5?file=).
72+
Try your [message item on CodeSandbox](https://codesandbox.io/s/2-1-customizing-messageitem-q38cg5).
7473

7574
```javascript
7675
<Channel
@@ -92,29 +91,32 @@ Try your [message item on CodeSandbox](https://codesandbox.io/s/2-1-customizing-
9291

9392
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`.
9493

95-
Try your [message list params on CodeSandbox](https://codesandbox.io/s/2-2-customizing-messagelistparams-45573).
94+
Try your [message list params on CodeSandbox](https://codesandbox.io/s/2-2-customizing-messagelistparams-3ipi0g).
9695

9796
> Note: On CodeSandbox’s preview, only the messages you sent will be displayed.
9897
9998
```javascript
10099
// Pass arguments in JSON data input format to the query instance.
101-
<Channel
102-
queries={{
103-
messageListParams: {
104-
senderUserIds: [USER_ID],
105-
prevResultSize: 30,
106-
includeReplies: false,
107-
includeReactions: false
108-
}
109-
}}
110-
>
100+
const [queries] = useState({
101+
// use object json type input, don't create sendbird query instance
102+
// https://sendbird.github.io/core-sdk-javascript/module-model_params_messageListParams-MessageListParams.html
103+
// https://github.com/sendbird/SendBird-SDK-JavaScript/blob/master/SendBird.d.ts#L488
104+
messageListParams: {
105+
senderUserIds: [USER_ID],
106+
prevResultSize: 30,
107+
includeReplies: false,
108+
includeReactions: false
109+
}
110+
});
111+
112+
<Channel queries={queries} />
111113
```
112114

113115
### Message params
114116

115117
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.
116118

117-
Try your [message params on CodeSandbox](https://codesandbox.io/s/2-3-customizing-messageparams-phqii)
119+
Try your [message params on CodeSandbox](https://codesandbox.io/s/2-3-customizing-messageparams-606156)
118120

119121
> Note: On the CodeSandbox’s preview, you can send or update a message in highlight.
120122
@@ -130,23 +132,23 @@ In order to complete an operation you intend to carry out with each function, yo
130132

131133
```javascript
132134
const handleUpdateUserMessage = (text) => {
133-
const userMessageParams = new sdk.UserMessageParams();
135+
const userMessageParams = {};
134136
userMessageParams.message = text;
135137
return userMessageParams;
136138
}
137139
```
138140

139-
Find out more about `UserMessageParams` and `FileMessageParams` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.github.io/core-sdk-javascript/module-model_params_userMessageParams-UserMessageParams.html).
141+
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).
140142

141143
### Chat header
142144

143145
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.
144146

145-
Try your [chat header on CodeSandbox](https://codesandbox.io/s/2-4-customizing-chatheader-voi0z)
147+
Try your [chat header on CodeSandbox](https://codesandbox.io/s/2-4-customizing-chatheader-mi5ijz)
146148

147149
```javascript
148150
<Channel
149-
renderChatHeader={({ channel, user }) => (
151+
renderChannelHeader={() => (
150152
<CustomizedHeader />
151153
)}
152154
>
@@ -158,12 +160,12 @@ Try your [chat header on CodeSandbox](https://codesandbox.io/s/2-4-customizing-c
158160

159161
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.
160162

161-
Try your [message input on CodeSandbox](https://codesandbox.io/s/2-5-customizing-chatinput-wgi9d)
163+
Try your [message input on CodeSandbox](https://codesandbox.io/s/2-5-customizing-messageinput-forked-or4lm8)
162164

163165

164166
```javascript
165167
<Channel
166-
renderMessageInput={({ channel, user, disabled }) => (
168+
renderMessageInput={() => (
167169
<CustomizedMessageInput />
168170
)}
169171
>
@@ -175,7 +177,7 @@ Try your [message input on CodeSandbox](https://codesandbox.io/s/2-5-customizing
175177

176178
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.
177179

178-
Try your [channel preview item on CodeSandbox](https://codesandbox.io/s/3-1-customizing-channelpreviewitem-ycsvs)
180+
Try your [channel preview item on CodeSandbox](https://codesandbox.io/s/3-1-customizing-channelpreviewitem-7c9xz6)
179181

180182
```javascript
181183
<ChannelList
@@ -190,46 +192,52 @@ Try your [channel preview item on CodeSandbox](https://codesandbox.io/s/3-1-cust
190192
You can make your own customized channel preview item component in this file. You can use the **onLeaveChannel** function in the component.
191193

192194
```javascript
193-
function CustomizedChannelPreviewItem(props) {
194-
const { channel, onLeaveChannel } = props;
195+
const CustomizedChannelPreviewItem = (props) => {
196+
const { channel } = props;
197+
const onLeaveChannel = sendbirdSelectors.getLeaveChannel(store);
195198
...
196199
onLeaveChannel(channel);
197200
}
198201
```
199202

200-
> Note: You can try making your own customized channel preview item by using `<CustomizedMessageItem />` and using the **onLeaveChannel** function in the component on the CodeSandbox sample.
201-
202203
### Channel list query
203204

204205
The **queries.channelListQuery** is an `instance` prop in the **ChannelList** component which filters channels by using its options.
205206

206-
Try your [channel list query item on CodeSandbox](https://codesandbox.io/s/3-2-customizing-channellistquery-z2y89?file=)
207+
Try your [channel list query item on CodeSandbox](https://codesandbox.io/s/3-2-customizing-channellistquery-d0t2l8)
207208

208209
> 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.
209210
210211
```javascript
211212
// Pass arguments in JSON data input format to the query instance.
213+
const [queries] = useState({
214+
channelListQuery: {
215+
includeEmpty: true,
216+
limit: 50,
217+
order: "chronological"
218+
// channelListQuery
219+
// https://sendbird.github.io/core-sdk-javascript/module-model_query_groupChannelListQuery-GroupChannelListQuery.html
220+
},
221+
applicationUserListQuery: {
222+
limit: 50
223+
// ex) userIdsFilter: ["sendbirdian", ...]
224+
// applicationUserListQuery
225+
// https://sendbird.github.io/core-sdk-javascript/module-model_query_applicationUserListQuery-ApplicationUserListQuery.html
226+
}
227+
});
228+
212229
<ChannelList
213-
queries={{
214-
channelListQuery: {
215-
includeEmpty: true,
216-
limit: 50,
217-
order: "chronological"
218-
},
219-
applicationUserListQuery: {
220-
limit: 50,
221-
}
222-
}}
230+
queries={queries}
223231
>
224232
```
225233

226-
Find out more about `ChannelListQuery` and `ApplicationUserListQuery` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.github.io/core-sdk-javascript/module-model_query_groupChannelListQuery-GroupChannelListQuery.html).
234+
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).
227235

228236
### Channel params
229237

230238
The **onBeforeCreateChannel** is a prop of the **ChannelList** component which can be implemented with custom code for events related to the corresponding user actions.
231239

232-
Try your [channel param on CodeSandbox](https://codesandbox.io/s/3-3-customizing-channellist-sg9kx)
240+
Try your [channel param on CodeSandbox](https://codesandbox.io/s/3-3-customizing-channelparams-vgcgtj)
233241

234242
> Note: you can create a channel using `GroupChannelParams`.
235243
@@ -242,7 +250,7 @@ You can get an array of **selectedUsers** in a function argument. In order to co
242250

243251
```javascript
244252
const handleOnBeforeCreateChannel = (selectedUsers) => {
245-
const channelParams = new sdk.GroupChannelParams();
253+
const channelParams = new sdk.GroupChannelCreateParams();
246254
channelParams.addUserIds(selectedUsers);
247255
channelParams.name = "Hello Sendbird!!";
248256
channelParams.overUrl = null;
@@ -253,16 +261,16 @@ const handleOnBeforeCreateChannel = (selectedUsers) => {
253261
}
254262
```
255263

256-
Find out more about `GroupChannelParams` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.github.io/core-sdk-javascript/module-model_params_groupChannelParams-GroupChannelParams.html).
264+
Find out more about `GroupChannelParams` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/interfaces/_sendbird_chat_groupChannel.GroupChannelCreateParams.html).
257265

258266
## Open Channel Samples
259267

260268
We also provide samples for open channels. Check below to see how you can implement and customize open channels.
261269

262270
### Live Streaming Sample
263271

264-
See how open channel on live stream works on [CodeSandBox](https://codesandbox.io/s/openchannel-1-bvxl9?file=/src/App.js).
272+
See how open channel on live stream works on [CodeSandBox](https://codesandbox.io/s/openchannel-1-ykexd3).
265273

266274
### Community Sample
267275

268-
See how you can create community channels on [CodeSandBox](https://codesandbox.io/s/openchannel-2-h7x3b?file=/src/App.js).
276+
See how you can create community channels on [CodeSandBox](https://codesandbox.io/s/openchannel-2-forked-5kpnqj).

0 commit comments

Comments
 (0)