feature: strongly type Table component

This commit is contained in:
Sammy Teillet
2023-04-20 13:49:43 +02:00
parent 887a7af5e2
commit c1883d381e

View File

@ -10,9 +10,9 @@ import TableHeader from './table-header/TableHeader';
import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { IconProp } from '@fortawesome/fontawesome-svg-core';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
type OwnProps = { type OwnProps<TData> = {
data: Array<any>; data: Array<TData>;
columns: Array<ColumnDef<any, any>>; columns: Array<ColumnDef<TData, any>>;
viewName: string; viewName: string;
viewIcon?: IconProp; viewIcon?: IconProp;
}; };
@ -60,7 +60,7 @@ const StyledTableWithHeader = styled.div`
flex: 1; flex: 1;
`; `;
function Table({ data, columns, viewName, viewIcon }: OwnProps) { function Table<TData>({ data, columns, viewName, viewIcon }: OwnProps<TData>) {
const table = useReactTable({ const table = useReactTable({
data, data,
columns, columns,