import { ScrollToTop } from "@/utilities"; import { useEffect, useRef } from "react"; import { TableInstance, usePagination } from "react-table"; import PageControl from "./PageControl"; import { useDefaultSettings } from "./plugins"; import SimpleTable, { SimpleTableProps } from "./SimpleTable"; type Props = SimpleTableProps & { autoScroll?: boolean; }; const tablePlugins = [useDefaultSettings, usePagination]; export default function PageTable(props: Props) { const { autoScroll, plugins, ...remain } = props; const instance = useRef | null>(null); // Scroll to top when page is changed useEffect(() => { if (autoScroll) { ScrollToTop(); } }, [instance.current?.state.pageIndex, autoScroll]); return ( <> {instance.current && ( )} ); }