useMediaList
A hook that flattens a list of messages into a flat array of media tiles for the MediaList grid. It keeps one tile per renderable image/video attachment, applying the same attachment rules the message list uses, and excludes scraped/OG link-preview attachments and non-media attachments.
Best Practices
- Feed it the messages returned by the media search source rather than building tiles by hand.
- Render the result in a grid
FlatList, one tile per entry. - Expect one tile per attachment — a message with multiple media attachments yields multiple tiles.
- Keep the
messagesreference stable across renders to avoid recomputing tiles. - Use the
messageon each tile when you need to open a gallery viewer or resolve the source message.
Parameters
| Parameter | Description | Type |
|---|---|---|
messages | The messages to extract image/video attachments from. | MessageResponse[] |
Return type
Returns a flat array of MediaTile, one per image/video attachment.
attachment
The image/video attachment rendered by the tile.
| Type |
|---|
Attachment |
message
The message the attachment belongs to.
| Type |
|---|
MessageResponse |