import { useChannelUpdated } from "stream-chat-react-native";
useChannelUpdated({
setChannels,
onChannelUpdated: (setChannels, event) => {
setChannels(
(channels) =>
channels?.map((channel) =>
channel.cid === (event.cid || event.channel?.cid) ? channel : channel,
) ?? channels,
);
},
});This is beta documentation for Stream Chat React Native SDK v9. For the latest stable version, see the latest version (v8)
.
useChannelUpdated
Subscribes to channel.updated events and applies channel updates to your ChannelList state.
Best Practices
- Use this hook where channel list state (
setChannels) is owned. - Provide a custom
onChannelUpdatedonly when default update behavior is insufficient. - Keep custom update handlers idempotent and side-effect free.
- Avoid mutating the previous channels array directly in custom handlers.
- Use this hook once per list state owner to prevent duplicate updates.
Usage
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| setChannels | React.Dispatch<React.SetStateAction<Channel[] | null>> | Yes | State setter for channel list data. |
| onChannelUpdated | (setChannels, event) => void | No | Optional custom channel.updated handler. |