import {
Chat,
Channel,
OverlayProvider,
MessageList,
} from "stream-chat-react-native";
const App = () => {
return (
<OverlayProvider>
<Chat client={client}>
<Channel channel={channel}>
<MessageList />
</Channel>
</Chat>
</OverlayProvider>
);
};MessageList
MessageList uses FlatList to render channel messages. It must be rendered inside Channel and uses message.type to pick the appropriate message view.
Best Practices
- Keep
MessageListinsideChannelso context and pagination work correctly. - Avoid heavy custom render logic per row; memoize where possible.
- Use
setFlatListRefinstead ofadditionalFlatListPropsfor refs. - Toggle
isLiveStreamingfor high-traffic channels to improve performance. - Be mindful of grouping/avatars if you disable
noGroupByUser.
General Usage
Props
additionalFlatListProps
Set additional props on the underlying FlatList.
const flatListProps = { bounces: true };
<MessageList additionalFlatListProps={flatListProps} />;Don't use additionalFlatListProps to access the FlatList ref, use setFlatListRef instead.
| Type |
|---|
Object | undefined |
inverted
Sets the inverted prop on underlying FlatList.
| Type | Default |
|---|---|
Boolean | undefined | true |
isListActive
Whether the list is active. Derived from isChannelActive in ChannelContext.
| Type | Default |
|---|---|
Boolean| undefined | false |
noGroupByUser
When true, consecutive messages from the same user are not grouped. The avatar shows only on the last message in the group.
| Type | Default |
|---|---|
Boolean | undefined | false |
onListScroll
Called when the list scrolls. Receives the underlying FlatList scroll event.
The event has the following shape (all values are numbers):
{
nativeEvent: {
contentInset: {bottom, left, right, top},
contentOffset: {x, y},
contentSize: {height, width},
layoutMeasurement: {height, width},
zoomScale
}
}| Type |
|---|
Function| undefined |
onThreadSelect
Called when the user selects a thread reply action or taps MessageReplies. Use it to navigate to the thread screen.
| Type |
|---|
Function | undefined |
setFlatListRef
Access the underlying FlatList ref.
Example
const flRef = useRef();
<MessageList setFlatListRef={(ref) => (flRef.current = ref)} />;| Type |
|---|
Function | undefined |
threadList
Whether messages are part of a thread.
| Type | Default |
|---|---|
Boolean | undefined | false |
isLiveStreaming
This component is available since version 8.6.2 of the SDK.
Enables internal MessageList optimizations for live-streaming.
| Type | Default |
|---|---|
Boolean | undefined | false |
UI Component Props
FooterComponent
Footer component. Because the list is inverted, this renders at the top. Defaults to an inline loading indicator while loading more.
| Type | Default |
|---|---|
ComponentType | undefined | InlineLoadingMoreIndicator |
HeaderComponent
Header component. Because the list is inverted, this renders at the bottom. Defaults to an inline loading indicator while loading more recent messages.
| Type | Default |
|---|---|
ComponentType | undefined | InlineLoadingMoreRecentIndicator |
ScrollToBottomButton
Renders the scroll-to-bottom button when the list isn't at the latest message.
| Type | Default |
|---|---|
| ComponentType | ScrollToBottomButton |
TypingIndicator
Renders the typing indicator inside MessageList.
| Type | Default |
|---|---|
| ComponentType | TypingIndicator |
DateHeader
Renders the sticky date header inside MessageList.
| Type | Default |
|---|---|
| ComponentType | DateHeader |