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 0 when no count is available, so you rarely need to guard for undefined when a channel is provided.
  • Prefer this hook over reading channel.data?.member_count directly so the UI stays in sync with channel.updated events.

Usage

import { useChannelMemberCount } from "stream-chat-react-native";

const memberCount = useChannelMemberCount(channel);

Parameters

NameTypeRequiredDescription
channelChannelNoChannel whose member count is read.

Returns

TypeDescription
number | undefinedThe channel's member count (0 when unset), or undefined if no channel.