UNPKG

material-react-table

Version:

A fully featured Material UI V6 implementation of TanStack React Table V8, written from the ground up in TypeScript.

45 lines (41 loc) 882 B
import { useMemo } from 'react'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, } from '../types'; import { getMRT_Rows } from '../utils/row.utils'; export const useMRT_Rows = <TData extends MRT_RowData>( table: MRT_TableInstance<TData>, ): MRT_Row<TData>[] => { const { getRowModel, getState, options: { data, enableGlobalFilterRankedResults, positionCreatingRow }, } = table; const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting, } = getState(); const rows = useMemo( () => getMRT_Rows(table), [ creatingRow, data, enableGlobalFilterRankedResults, expanded, getRowModel().rows, globalFilter, pagination.pageIndex, pagination.pageSize, positionCreatingRow, rowPinning, sorting, ], ); return rows; };