Channel List for PubNub Chat Components for React
Migrate to Chat SDK
PubNub will stop supporting Chat Components on January 1, 2025 but you are welcome to contribute. Learn how to migrate to the Chat SDK here.
Renders an interactive list of channels.
It can represent all channels of the application, only channels joined by the current user, all channels available to be joined, or whatever else is passed into it. A common pattern in chat applications is to render two instances of the component - one visible all the time to show joined channels, and another one hidden inside a modal with channels available to join. Make sure to handle the onChannelSwitched event to switch the current channel passed to the Chat provider.
Component
This section shows the preview of a sample Channel List component and its source code.
- Preview
- Source Code
Company Culture
Company culture space
Daily Standup
Async virtual standup
Exec AMA
Ask the CEO anything
India Office
भारत के कार्यालय में आपका स्वागत है🇮🇳!
Introductions
This channel is for company wide chatter
London Office
London Office 🇬🇧
Movies
Everything about movies
Off Topic
Non-work banter and water cooler conversation
Poland Office
Zapytaj Nas O Cokolwiek 🇵🇱
Running
soc-running space
<Chat currentChannel="space.2ada61db17878cd388f95da34f9">
<ChannelList
channels={[
{
"name": "Movies",
"custom": {
"profileUrl": "https://www.gravatar.com/avatar/149e60f311749f2a7c6515f7b34?s=256&d=identicon"
},
"description": "Everything about movies",
"eTag": "AbOx6N+6vu3zoAE",
"id": "space.149e60f311749f2a7c6515f7b34",
"updated": "2020-09-23T09:23:37.175764Z"
},
{
"name": "Daily Standup",
show all 106 linesParameters
You can configure the component using these parameters:
Parameter | Type | Default value | Description |
---|---|---|---|
channels | ChannelEntity[] | string[] | n/a | Option to pass a list of channels, including metadata, to render on the list. |
sort? | (a: ChannelEntity, b: ChannelEntity) => -1 | 0 | 1 | n/a | Channels are sorted alphabetically by default, you can override that by providing a sorter function. |
extraActionsRenderer? | (channel: ChannelEntity) => JSX.Element | n/a | Option to provide an extra actions renderer to add custom action buttons to each channel. |
channelRenderer? | (channel: ChannelEntity) => JSX.Element | n/a | Option to provide a custom channel renderer to override default themes and CSS variables. |
onChannelSwitched? | (channel: ChannelEntity) => unknown | n/a | Callback run when a user clicked one of the channels. Can be used to switch the current channel. |