This is documentation for Stream Chat React SDK v13, which is no longer actively maintained. For up-to-date documentation, see the latest version (v14).

MessageListContext

The context value is provided by MessageListContextProvider, which wraps the content rendered by MessageList. It exposes API used by default and custom components. Components that can consume MessageListContext include:

Best Practices

  • Use context values instead of querying DOM elements directly.
  • Keep custom components aligned with the default loading/empty states.
  • Use listElement and scrollToBottom for custom scrolling UX.
  • Avoid heavy logic inside list-level components to keep renders smooth.
  • Treat notification components as transient UI and keep them lightweight.

Basic Usage

Pull the value from context with our custom hook:

import { useMessageListContext } from "stream-chat-react";

export const CustomComponent = () => {
  const { listElement, scrollToBottom } = useMessageListContext();
  // component logic ...
  return {
    /* rendered elements */
  };
};

Values

listElement

The scroll container that renders messages and the typing indicator. You can use it to implement custom scroll behavior.

Type
HTMLDivElement | null

scrollToBottom

Scrolls the listElement to the bottom.

Type
() => void