Chat Viewer
    Preparing search index...

    Function followEveryMessage

    • Performs a scroll to the bottom of the chat viewer when a new message is added. It returns a generic OnMessagesCallback that can be used with the chat viewer.

      This function handles layout shifts that may occur after scrolling (e.g., when content like delimiters is rendered asynchronously). It monitors scrollSize changes and re-scrolls until the content stabilizes, ensuring the bottom remains visible.

      Type Parameters

      Parameters

      • opts: ScrollToIndexOpts = DEFAULT_SCROLL_OPTS

        ScrollToItemOpts options for controlling the scroll behavior

      Returns OnMessagesCallback<M>

      A callback that performs the scroll action.

      <ChatViewer
      messages={messages}
      renderMessage={renderMessage}
      onNewerMessages={followEveryMessage({ smooth: true })}
      />