useChannelDetailsActionItems

A hook that builds the channel action rows (mute, leave, delete, block, etc.) rendered by the actions section of ChannelDetails. It wraps the shared useChannelActionItems for the channel resolved from the ChannelDetailsContext, and augments the dismissing actions (leave, deleteChannel, block) so they invoke onChannelDismiss once the action succeeds.

Best Practices

  • Use it inside a ChannelDetailsContextProvider, since it resolves the channel from that context.
  • Provide onChannelDismiss to navigate away once the channel is no longer available to the current user (leave, delete, or block).
  • Customize the action list through getChannelActionItems (filter, reorder, replace, or add items) instead of rebuilding the section.
  • Keep your getChannelActionItems reference stable (memoize it) to avoid unnecessary recomputation.
  • Identify actions by their id rather than by index.

Parameters

The hook accepts a single options object.

ParameterDescriptionType
getChannelActionItemsCustomizes the list of action items. Receives the default items and returns the final list to render.GetChannelActionItems
onChannelDismissFired after a dismissing action (leave, delete, or block) succeeds and the channel is no longer available.() => void

Return type

Returns an array of ChannelActionItem ready to render in the actions section.

Type
ChannelActionItem[]