PaginatedMessageListContext

PaginatedMessageListContext is provided by Channel. If you are not familiar with the React Context API, see the React docs.

Best Practices

  • Use usePaginatedMessageListContext for consistent access and typings.
  • Check hasMore before triggering pagination.
  • Use loadingMore flags to prevent duplicate loads.
  • Avoid manual message array mutations; rely on context updates.
  • Keep pagination handlers lightweight to preserve scroll performance.

Basic Usage

Consume PaginatedMessageListContext in any child of Channel:

import { useContext } from "react";
import { PaginatedMessageListContext } from "stream-chat-react-native";

const { loadingMore, loadMoreRecent, messages } = useContext(
  PaginatedMessageListContext,
);

Alternatively, use the usePaginatedMessageListContext hook.

import { usePaginatedMessageListContext } from "stream-chat-react-native";

const { loadingMore, loadMoreRecent, messages } =
  usePaginatedMessageListContext();

Values

ValueDescriptionType
hasMoreFalse if Channel has loaded all history via pagination. Used to decide whether to load more when the user reaches the top of MessageList.boolean
loadingMoreTrue while Channel is querying older messages. Used to show/hide the inline loading indicator at the top of MessageList.boolean
loadingMoreRecentTrue while Channel is querying newer messages. Used to show/hide the inline loading indicator at the bottom of MessageList.boolean
loadLatestMessagesLoads the latest messages in the channel, jumping to the most recent state.() => Promise<void>
loadMoreLoads more messages before the top message. Called from the underlying FlatList onScroll when the user reaches the top and hasMore is true.(limit?: number) => Promise<void>
loadMoreRecentLoads more recent messages. Called from the underlying FlatList onScroll when the user reaches the relevant edge.(limit?: number) => Promise<void>
messagesMessages currently loaded in the channel.ChannelState['messages']
setLoadingMoreSetter for loadingMore.(loadingMore: boolean) => void
setLoadingMoreRecentSetter for loadingMoreRecent.(loadingMoreRecent: boolean) => void
viewabilityChangedCallbackA callback to be passed to onViewableItemsChanged in the underlying MessageList. Used internally to track which messages are visible.(config: ViewabilityChangedCallbackInput) => void