import { useChannelMemberCount } from "stream-chat-react-native";
const memberCount = useChannelMemberCount(channel);useChannelMemberCount
Reads channel.data?.member_count reactively (defaulting to 0) and re-renders when the channel is updated.
Best Practices
- Use this hook to display member counts in channel headers and details screens.
- Treat the value as read-only state derived from the channel store.
- The hook defaults to
0when no count is available, so you rarely need to guard forundefinedwhen a channel is provided. - Prefer this hook over reading
channel.data?.member_countdirectly so the UI stays in sync withchannel.updatedevents.
Usage
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| channel | Channel | No | Channel whose member count is read. |
Returns
| Type | Description |
|---|---|
number | undefined | The channel's member count (0 when unset), or undefined if no channel. |