import { useChannelName } from "stream-chat-react-native";
const name = useChannelName(channel);useChannelName
Reads channel.data?.name reactively and re-renders when the channel is updated.
Best Practices
- Use this hook to render the channel name in headers, previews, and details screens.
- Treat the value as read-only state derived from the channel store.
- Handle
undefinedwhen the channel has no name or is unavailable. - Prefer this hook over reading
channel.data?.namedirectly so the UI stays in sync withchannel.updatedevents. - Combine with a display-name fallback (e.g. member names) for direct messages without an explicit name.
Usage
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| channel | Channel | No | Channel whose name is read. |
Returns
| Type | Description |
|---|---|
string | undefined | The channel's name, or undefined if not set. |