UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

34 lines (33 loc) 1.79 kB
import * as React from 'react'; import type { CellProps, Row, TableInstance, TableState } from '../../react-table/react-table.js'; import type { Virtualizer, VirtualItem } from '@tanstack/react-virtual'; /** * Memoization is needed to avoid unnecessary re-renders of all rows when additional data is added when lazy-loading. * Using `isLast` here instead of passing data length to avoid re-renders of all rows when more data is added. Now only the last row re-renders. * Although state is not used it is needed for `React.memo` to check state that changes row state e.g. selection. * When adding new features check whether it changes state that affects row. If it does then add equality check to `React.memo`. */ export declare const TableRow: <T extends Record<string, unknown>>(props: { row: Row<T>; rowProps?: (row: Row<T>) => React.ComponentPropsWithRef<"div"> & { status?: "positive" | "warning" | "negative"; isLoading?: boolean; }; isLast: boolean; onRowInViewport: React.MutableRefObject<((rowData: T) => void) | undefined>; onBottomReached: React.MutableRefObject<(() => void) | undefined>; intersectionMargin: number; state: TableState<T>; onClick?: (event: React.MouseEvent, row: Row<T>) => void; subComponent?: (row: Row<T>) => React.ReactNode; isDisabled: boolean; tableHasSubRows: boolean; tableInstance: TableInstance<T>; expanderCell?: (cellProps: CellProps<T>) => React.ReactNode; scrollContainerRef: HTMLDivElement | null; tableRowRef?: React.Ref<HTMLDivElement>; density?: "default" | "condensed" | "extra-condensed"; virtualItem?: VirtualItem; virtualizer?: Virtualizer<Element, Element>; }) => React.JSX.Element; export declare const TableRowMemoized: typeof TableRow;