UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

46 lines (45 loc) 2.41 kB
import type { PropsWithChildren } from 'react'; import React from 'react'; import type { PaginatorProps } from '../../types/types'; export type InfiniteScrollProps = PaginatorProps & { className?: string; element?: React.ElementType; /** * @desc Flag signalling whether more pages with older items can be loaded * @deprecated Use hasPreviousPage prop instead. Planned for removal: https://github.com/GetStream/stream-chat-react/issues/1804 */ hasMore?: boolean; /** * @desc Flag signalling whether more pages with newer items can be loaded * @deprecated Use hasNextPage prop instead. Planned for removal: https://github.com/GetStream/stream-chat-react/issues/1804 */ hasMoreNewer?: boolean; /** Element to be rendered at the top of the thread message list. By default, Message and ThreadStart components */ head?: React.ReactNode; initialLoad?: boolean; isLoading?: boolean; listenToScroll?: (offset: number, reverseOffset: number, threshold: number) => void; loader?: React.ReactNode; /** * @desc Function that loads previous page with older items * @deprecated Use loadPreviousPage prop instead. Planned for removal: https://github.com/GetStream/stream-chat-react/issues/1804 */ loadMore?: () => void; /** * @desc Function that loads next page with newer items * @deprecated Use loadNextPage prop instead. Planned for removal: https://github.com/GetStream/stream-chat-react/issues/1804 */ loadMoreNewer?: () => void; useCapture?: boolean; }; /** * This component serves a single purpose - load more items on scroll inside the MessageList component * It is not a general purpose infinite scroll controller, because: * 1. It is re-rendered whenever queryInProgress, hasNext, hasPrev changes. This can lead to scrollListener to have stale data. * 2. It pretends to invoke scrollListener on resize event even though this event is emitted only on window resize. It should * rather use ResizeObserver. But then again, it ResizeObserver would invoke a stale version of scrollListener. * * In general, the infinite scroll controller should not aim for checking the loading state and whether there is more data to load. * That should be controlled by the loading function. */ export declare const InfiniteScroll: (props: PropsWithChildren<InfiniteScrollProps>) => React.JSX.Element;