import { createContext, useContext } from "react"; export interface TableContextProps { count: number; page: number; rowsPerPage: number; rowsPerPageOptions: number[]; changePage: (event: React.MouseEvent | null, newPage: number) => void; changeRowsPerPage: (event: React.ChangeEvent) => void; } export const TableContext = createContext( undefined as unknown as TableContextProps, ); export const useTableContext = () => { const context = useContext(TableContext); if (context == null) { throw new Error( "useTableContext must be used within a TableProvider. You are most likely not using the correct parent component.", ); } return context; };