Open Channel list
A channel list shows a complete list of open channels available for the current user using the openChannelList
module. Once the client app is connected to the Sendbird server, you can display the channel list. All chat services built with Sendbird UIKit begin from the channel list.
Usage
To start using the OpenChannelList
module, implement the following code:
List of properties
The following table lists the properties of the OpenChannelList
module.
Required | Type | Description |
---|---|---|
onChannelSelected | function | Specifies the prop to receive callback when selecting a channel in the channel list. |
Optional | Type | Description |
---|---|---|
queries | object | Specifies an object { openChannelListQuery: OpenChannelListQueryParams } |
className | string | Specifies the CSS custom name of the class. (Default: |
renderHeader | ReactElement | Renders a customized header component to replace the default header. The following are given as arguments: |
renderPlaceHolderError | ReactElement | Renders a customized placeholder for an error status in the channel list. (Default: |
renderPlaceHolderLoading | ReactElement | Renders a customized placeholder for a loading status in the channel list. (Default: |
renderPlaceHolderEmpty | ReactElement | Renders a customized placeholder for an empty list status when the channel list is empty. (Default: |
renderChannelPreview | ReactElement | Renders a customized channel preview component to replace the default |
Context
To store and handle data that are used to build a working channel list, Sendbird UIKit provides two context objects: OpenChannelListProvider
and useOpenChannelListContext
hook. OpenChannelListProvider
is a provider that manages all the logic and data used in the channel list view. The useOpenChannelListContext
is a context hook that allows access to the provider's data.
OpenChannelListProvider
OpenChannelListProvider
contains input props and internal data that handle all the operations in the module. The provider stores data from Chat SDK in real-time and exports them to the UI components. The following code shows how to start using OpenChannelListProvider
.
List of properties
The following table lists the properties of OpenChannelListProvider
.
Required | Type | Description |
---|---|---|
onChannelSelected | function | Specifies the prop to receive callback when selecting a channel in the channel list. |
Optional | Type | Description |
---|---|---|
queries | object | Specifies an object { openChannelListQuery: OpenChannelListQueryParams } |
className | string | Specifies the CSS custom name of the class. (Default: |
useOpenChannelListContext
The useOpenChannelListContext
context hook exports the data in the provider to the UI components to create a functional view of the channel list. Every UI component of any layer or level can get access to the data using the context hooks as long as they're inside the provider.
The following code shows how to start using useOpenChannelListContext
.
List of properties
The following table lists the properties of useOpenChannelListContext
.
Property name | Type | Description |
---|---|---|
onChannelSelected | function | Specifies the prop to receive callback when selecting a channel in the channel list. |
customOpenChannelListQuery | object | Specifies an OpenChannelListQueryParams. |
logger | Logger | Specifies a logger |
currentChannel | object | Specifies a current channel |
allChannels | array of objects | Specifies a list of channels that are loaded in the list. |
fetchingStatus | string | Specifies a current fetching status. |
fetchNextChannels | function | Loads more channels in the list. |
refreshOpenChannelList | function | Refreshes the list of channels. |
openChannelListDispatcher | object | Specifies a open channel dispatcher. |
UI components
The UI components in the OpenChannelList
module are the following: OpenChannelListUI
and OpenChannelPreview
. They're the default set of UI components that compose the channel list view.
OpenChannelListUI
OpenChannelListUI
is the component that displays the basic screen of the module. It contains placeholders for error and loading statuses and renders the header and channel preview. The following code shows how to implement OpenChannelListUI
.
List of properties
The following table lists the properties of OpenChannelListUI
.
Property name | Type | Description |
---|---|---|
renderHeader | ReactElement | Renders a customized header component to replace the default header. The following are given as arguments: |
renderPlaceHolderError | ReactElement | Renders a customized placeholder for an error status in the channel list. (Default: |
renderPlaceHolderLoading | ReactElement | Renders a customized placeholder for a loading status in the channel list. (Default: |
renderPlaceHolderEmpty | ReactElement | Renders a customized placeholder for an empty list status when the channel list is empty. (Default: |
renderChannelPreview | ReactElement | Renders a customized channel preview component to replace the default |
OpenChannelPreview
OpenChannelPreview
is a component that displays a single channel in the list item UI. You can customize this component using renderChannelPreview
.
The following code shows how to implement OpenChannelPreview
.
List of properties
Property name | Type | Description |
---|---|---|
channel | instance | Specifies the channel instance shown in the list item. (Default: |
onClick | function | Specifies the prop to select a channel item in the list. (Default: |
isSelected | boolean | Determines whether the channel displayed in the list item UI is currently active. (Default: |