Chat Viewer
    Preparing search index...

    Function followMessagesBy

    • Performs a scroll to the bottom of the chat when a message matches the provided condition. This is useful for following specific messages that meet a certain criteria, such as mentions or keywords. Typical behavior of the chat apps is to scroll to the bottom when a new message arrives, but only if the user is already at the bottom of the chat. When user scrolls up to view older messages, it will not scroll automatically. When browsing messages history chat apps usually scroll to the bottom only when user sends a new message.

      Type Parameters

      Parameters

      • shouldFollow: (message: M) => boolean

        A function that determines if any of the received messages should trigger a scroll action.

      • 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={followMessagesBy(
      message => message.type === 'mention'
      )}
      />