---
id: message-list
title: MessageList
---

`MessageList` component uses [`FlatList`](https://reactnative.dev/docs/flatlist) to render list of messages within a channel (provided as a prop to parent `Channel` component).
This component must be rendered within `Channel` component. It uses `message.type` property, to render corresponding view for message.

Additionally it also renders following building blocks for message list:

- `DateHeader` - which is a sticky header at top of the list and updates as you scroll up within list.
- `InlineDateSeparator` - which act as separators for messages from different dates
- `ScrollToBottomButton` - which when pressed, scrolls the list to most recent message.

## Basic Usage

```tsx
<OverlayProvider>
  <Chat client={client}>
    <Channel channel={channel}>
      <MessageList />
    </Channel>
  </Chat>
</OverlayProvider>
```

## Props

### additionalFlatListProps

Set any additional props on underlying [FlatList](https://reactnative.dev/docs/flatlist#props).

```jsx
const flatListProps = { bounces: true };

<MessageList additionalFlatListProps={flatListProps} />
```

:::caution

Don't use `additionalFlatListProps` to access the FlatList ref, use [`setFlatListRef`](#setflatlistref) instead.

:::

| Type |
| - |
| object |

### inverted

Sets the `inverted` prop on underlying [FlatList](https://reactnative.dev/docs/flatlist#inverted)

| Type | Default |
| - | - |
| boolean | true |

### noGroupByUser

When true, consecutive messages from same user won't be grouped together. Avatar for user of message is only shown for last message of the group.

| Type | Default |
| - | - |
| boolean | false |

### onListScroll

Callback function which gets called when list scrolls. This function receives scroll event from underlying FlatList as param.

The event has the following shape (all values are numbers):

```js
{
  nativeEvent: {
    contentInset: {bottom, left, right, top},
    contentOffset: {x, y},
    contentSize: {height, width},
    layoutMeasurement: {height, width},
    zoomScale
  }
}
```

| Type |
| - |
| function |

### onThreadSelect

Function which gets called when user presses on `"Thread Reply"` action from message actions or `MessageReplies` component which displays the number of thread replies on the message.
You should put navigation logic to switch to Thread Screen within this function.

| Type |
| - |
| function |

### setFlatListRef

Use this callback function to gain access to the underlying FlatList ref.

#### Example

```jsx
const flRef = useRef();

<MessageList setFlatListRef={(ref) => flRef.current = ref} />
```

| Type |
| - |
| function |

<!-- ### threadList

Boolean whether or not the Messages in the MessageList are part of a Thread.

| Type |
| - |
| function | -->

### FooterComponent

Component to render footer for MessageList component. Since we use inverted FlatList, this component will be rendered at top of the list.
In absence of this prop, an inline loading indicator will be rendered when channel is loading more results.

| Type | Default |
| - | - |
| component | [InlineLoadingMoreIndicator](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/MessageList/InlineLoadingMoreIndicator.tsx) |

### HeaderComponent

Component to render header for MessageList component. Since we use inverted FlatList, this component will be rendered at bottom of the list.
In absence of this prop, an inline loading indicator will be rendered when channel is loading more results.

| Type | Default |
| - | - |
| component | [InlineLoadingMoreRecentIndicator](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/MessageList/InlineLoadingMoreRecentIndicator.tsx) |

