import React, { Dispatch, FC, ReactNode, RefObject, SetStateAction } from 'react'; import { useColumnReverseInfiniteScroll } from '../require/react-helper'; import Retry from './retry'; export interface InfiniteScrollProps { infiniteScrollElementRef: RefObject; fetchRetryCallable: () => Promise; fetchAboveCallable: () => Promise; fetchBelowCallable: () => Promise; setScrollRatio: Dispatch>; ends: { hasMoreAbove: boolean, hasMoreBelow: boolean } | null; fetchError: unknown | null; fetchAboveError: unknown | null; fetchBelowError: unknown | null; fetchErrorMessage: string; fetchAboveErrorMessage: string; fetchBelowErrorMessage: string; children: ReactNode; } // Implements convenient features such as 'try again' components const InfiniteScroll: FC = (props: InfiniteScrollProps) => { const { infiniteScrollElementRef, fetchRetryCallable, fetchAboveCallable, fetchBelowCallable, setScrollRatio, ends, fetchError, fetchAboveError, fetchBelowError, fetchErrorMessage, fetchAboveErrorMessage, fetchBelowErrorMessage, children } = props; const [ updateScrollCallable, fetchAboveRetry, fetchBelowRetry ] = useColumnReverseInfiniteScroll( 600, ends, fetchAboveCallable, fetchBelowCallable, setScrollRatio ); return (
{children}
) }; export default InfiniteScroll;