VirtualizedMessageListContext

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

Best Practices

  • Use context helpers instead of directly manipulating virtualized DOM.
  • Keep custom components compatible with virtualization constraints.
  • Prefer lightweight notifications to avoid virtualized list jitter.
  • Use scrollToBottom for UX flows like “new messages” buttons.
  • Avoid measuring DOM nodes in list items when possible.

Basic Usage

Pull the value from context with our custom hook:

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

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

Values

scrollToBottom

Scrolls the list to the bottom.

Type
() => void