import { useChannelPreviewDisplayPresence } from "stream-chat-react-native";
const PreviewAvatar = ({ channel }: { channel: Channel }) => {
const showPresence = useChannelPreviewDisplayPresence(channel);
return <ChannelAvatar channel={channel} showOnlineIndicator={showPresence} />;
};This is beta documentation for Stream Chat React Native SDK v9. For the latest stable version, see the latest version (v8)
.
useChannelPreviewDisplayPresence
Returns whether avatar presence should be shown for a channel preview.
This hook returns true only for one-to-one channels where the other member is online.
Best Practices
- Use this hook for direct-message previews, not group channels.
- Pair presence indicators with lightweight UI to keep scrolling smooth.
- Avoid separate client event subscriptions in list rows.
- Treat the return value as derived UI state and render conditionally.
- Keep presence rendering consistent with your app's avatar patterns.
Usage
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| channel | Channel | Yes | Channel used to derive presence state. |
Returns
| Type | Description |
|---|---|
boolean | Whether to display online presence in a channel preview row. |