Skip to content

Commit 544e7d0

Browse files
authored
doc: update onBeforeCreateChannel example to V4(#401)
Update SAMPLES.md, convert onBeforeCreateChannel example from V3 to V4 thanks @tylerhammer
1 parent 6784ec2 commit 544e7d0

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

SAMPLES.md

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Sendbird UIKit for React samples
2+
23
![Platform](https://img.shields.io/badge/platform-JAVASCRIPT-orange.svg)
34
![Languages](https://img.shields.io/badge/language-JAVASCRIPT-orange.svg)
45
[![npm](https://img.shields.io/npm/v/sendbird.svg?style=popout&colorB=red)](https://www.npmjs.com/package/sendbird)
@@ -21,6 +22,7 @@ Find out more about Sendbird UIKit for React at [UIKit for React doc](https://se
2122
<br />
2223

2324
## UIKit components and ways to customize
25+
2426
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.
2527

2628
<br />
@@ -41,12 +43,12 @@ The minimum requirements for UIKit for React are:
4143

4244
### Implement Chat with App component
4345

44-
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 [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.
4547

4648
Try setting your own by downloading the Sendbird sample.
4749

4850
```javascript
49-
import SendbirdApp from '@sendbird/uikit-react/App'
51+
import SendbirdApp from '@sendbird/uikit-react/App';
5052
```
5153

5254
### Import components to customize UIKit
@@ -107,18 +109,18 @@ Try your [message list params on CodeSandbox](https://codesandbox.io/s/2-2-custo
107109
```javascript
108110
// Pass arguments in JSON data input format to the query instance.
109111
const [queries] = useState({
110-
// use object json type input, don't create sendbird query instance
111-
// https://sendbird.github.io/core-sdk-javascript/module-model_params_messageListParams-MessageListParams.html
112-
// https://github.com/sendbird/SendBird-SDK-JavaScript/blob/master/SendBird.d.ts#L488
113-
messageListParams: {
114-
senderUserIds: [USER_ID],
115-
prevResultSize: 30,
116-
includeReplies: false,
117-
includeReactions: false
118-
}
112+
// use object json type input, don't create sendbird query instance
113+
// https://sendbird.github.io/core-sdk-javascript/module-model_params_messageListParams-MessageListParams.html
114+
// https://github.com/sendbird/SendBird-SDK-JavaScript/blob/master/SendBird.d.ts#L488
115+
messageListParams: {
116+
senderUserIds: [USER_ID],
117+
prevResultSize: 30,
118+
includeReplies: false,
119+
includeReactions: false,
120+
},
119121
});
120122

121-
<Channel queries={queries} />
123+
<Channel queries={queries} />;
122124
```
123125

124126
### Message params
@@ -141,10 +143,10 @@ In order to complete an operation you intend to carry out with each function, yo
141143

142144
```javascript
143145
const handleUpdateUserMessage = (text) => {
144-
const userMessageParams = {};
145-
userMessageParams.message = text;
146-
return userMessageParams;
147-
}
146+
const userMessageParams = {};
147+
userMessageParams.message = text;
148+
return userMessageParams;
149+
};
148150
```
149151

150152
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).
@@ -171,7 +173,6 @@ The **renderMessageInput** is a `ReactElement` prop in the **Channel** component
171173

172174
Try your [message input on CodeSandbox](https://codesandbox.io/s/2-5-customizing-messageinput-forked-or4lm8)
173175

174-
175176
```javascript
176177
<Channel
177178
renderMessageInput={() => (
@@ -234,7 +235,7 @@ Try your [channel list query item on CodeSandbox](https://codesandbox.io/s/3-2-c
234235
// https://sendbird.github.io/core-sdk-javascript/module-model_query_applicationUserListQuery-ApplicationUserListQuery.html
235236
}
236237
});
237-
238+
238239
<ChannelList
239240
queries={queries}
240241
>
@@ -255,22 +256,24 @@ Try your [channel param on CodeSandbox](https://codesandbox.io/s/3-3-customizing
255256
onBeforeCreateChannel={handleOnBeforeCreateChannel}
256257
>
257258
```
258-
You can get an array of **selectedUsers** in a function argument. In order to complete an operation you intend to carry out with the function, you should return a `GroupchannelParams` object after specifying its properties.
259+
260+
You can get an array of **selectedUsers** in a function argument. In order to complete an operation you intend to carry out with the function, you should return an instance of `GroupChannelCreateParams` object after specifying its properties.
259261

260262
```javascript
261263
const handleOnBeforeCreateChannel = (selectedUsers) => {
262-
const channelParams = new sdk.GroupChannelCreateParams();
263-
channelParams.addUserIds(selectedUsers);
264-
channelParams.name = "Hello Sendbird!!";
265-
channelParams.overUrl = null;
266-
channelParams.coverImage = null;
267-
channelParams.customType = HIGHLIGHT;
268-
269-
return channelParams;
270-
}
264+
const channelParams: GroupChannelCreateParams = {
265+
name: 'Hello Sendbird!',
266+
invitedUserIds: selectedUsers,
267+
coverUrl: null,
268+
customType: HIGHLIGHT,
269+
isDistinct: true,
270+
};
271+
272+
return channelParams;
273+
};
271274
```
272275

273-
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).
276+
Find out more about `GroupChannelCreateParams` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/interfaces/_sendbird_chat_groupChannel.GroupChannelCreateParams.html).
274277

275278
## Open Channel Samples
276279

0 commit comments

Comments
 (0)