import { TouchableOpacity } from "react-native-gesture-handler";
import { ChannelList, ChannelAvatar } from "stream-chat-react-native";
<ChannelList
PreviewAvatar={({ channel }) => (
<TouchableOpacity
disallowInterruption={true}
onPress={() => {
/** Handler for press action */
}}
>
<ChannelAvatar channel={channel} />
</TouchableOpacity>
)}
/>;This is beta documentation for Stream Chat React Native SDK v9. For the latest stable version, see the latest version (v8)
.
ChannelAvatar
Renders a channel avatar inside ChannelList.
Best Practices
- Keep avatar rendering lightweight to avoid list performance issues.
- Use
PreviewAvatarto wrap interactions without alteringChannelAvatarinternals. - Ensure touch targets are accessible when adding custom
onPress. - Use the context-provided
ImageComponentfor consistent image handling. - Avoid inline handlers when rendering large lists; memoize where possible.
General Usage
Customize it and pass it via PreviewAvatar on ChannelList.
Example with an onPress handler:
Props
channel
Channel instance from the Stream Chat client.
| Type |
|---|
| Channel |
showOnlineIndicator
Indicates if the online indicator should be shown.
| Type | Default |
|---|---|
| Boolean | true |
size
Size of the avatar. Default: xl.
| Type | Default |
|---|---|
lg | xl | 2xl | xl |
showBorder
Indicates if the border should be shown.
| Type | Default |
|---|---|
| Boolean | true |