import { useChannelPreviewDisplayName } from "stream-chat-react-native";
const ChannelName = ({ channel }: { channel: Channel }) => {
const displayName = useChannelPreviewDisplayName(channel);
return <Text>{displayName ?? "Unknown channel"}</Text>;
};This is beta documentation for Stream Chat React Native SDK v9. For the latest stable version, see the latest version (v8)
.
useChannelPreviewDisplayName
Computes a display name for a channel preview using channel name or member names.
Best Practices
- Prefer this hook over ad-hoc member-name formatting in list rows.
- Use channel names when available for predictable labeling.
- Handle channels with missing member data gracefully.
- Keep custom naming logic localized to one place for consistency.
- Expect group-channel output in the form
Name1, Name2 and N others.
Usage
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| channel | Channel | No | Channel used to resolve display name. |
Returns
| Type | Description |
|---|---|
string | undefined | Computed display name for the channel preview title. |