import {
ChannelDetails,
GetChannelDetailsNavigationItems,
} from "stream-chat-react-native";
const getNavigationItems: GetChannelDetailsNavigationItems = ({
defaultItems,
}) =>
defaultItems.map((item) =>
item.section === "files"
? { ...item, onPress: () => navigation.navigate("ChannelFiles") }
: item,
);
const ChannelDetailsScreen = () => (
<ChannelDetails getNavigationItems={getNavigationItems} />
);useChannelDetailsNavigationItems
A hook that builds the navigation rows rendered by the navigation section of ChannelDetails — the entry points to the PinnedMessageList, MediaList and FileAttachmentList. It returns the items as a plain array; the section component owns the built-in modal and supplies the default open-modal behavior for any row without a custom onPress.
Best Practices
- Customize rows by passing
getNavigationItems, mapping overdefaultItemsto set a row'sonPress(e.g. to push your own screen) or to add/remove rows. - Leave a row's
onPressunset to keep its built-in modal behavior — including sections added in future SDK versions. - Use the already-translated
labelondefaultItemsinstead of re-translating section names. - Keep your
getNavigationItemsreference stable (memoize it) to avoid unnecessary recomputation. - Identify rows by
sectionrather than by index, since the order can change.
Parameters
The hook accepts a single options object.
| Parameter | Description | Type |
|---|---|---|
getNavigationItems | Customizes the navigation rows. Receives the built-in defaultItems (and a context) and returns the rows to render. Defaults to returning defaultItems unchanged. | GetChannelDetailsNavigationItems |
The GetChannelDetailsNavigationItems callback receives:
| Property | Description | Type |
|---|---|---|
context | Carries the translation function t. | ChannelDetailsNavigationItemsContext |
defaultItems | The built-in navigation rows, in render order. | ChannelDetailsNavigationItem[] |
Return type
Returns an array of ChannelDetailsNavigationItem, each describing one row.
Icon
Icon rendered at the start of the row and reused in the built-in modal header.
| Type |
|---|
React.ComponentType<IconProps> |
label
Already-translated label rendered for the row and its built-in modal header.
| Type |
|---|
string |
section
Identifies which section the row represents. The built-in sections are pinned-messages, photos-and-videos and files; custom rows can use any string.
| Type |
|---|
ChannelDetailsNavigationSectionType |
onPress
Fired when the user taps the row. Leave unset to keep the built-in modal behavior; set it to route the row elsewhere.
| Type |
|---|
() => void |