-
Hello, I would like to make a generic table component by using Here is my code which gets a typescript error: import {
createTable,
useTableInstance,
getCoreRowModel,
} from '@tanstack/react-table';
type TableProps<T extends object> = {
data: T[];
columns: {
id: string;
title: keyof T;
}[];
};
export const Table = <T extends object>({ data, columns }: TableProps<T>) => {
const table = createTable().setRowType<T>();
const instance = useTableInstance(table, {
data,
columns: columns.map(column =>
table.createDataColumn(column.title, {
id: column.id,
cell: info => info.getValue(),
footer: props => props.column.id,
}),
),
getCoreRowModel: getCoreRowModel(),
});
}; The error is on the second argument of Thanks, |
Beta Was this translation helpful? Give feedback.
Answered by
mc-petry
Jun 16, 2022
Replies: 1 comment
-
As temporary workaround try this one: table.createDataColumn<AccessorFn<T>>(column.title as any, ...) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jvnm-dev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As temporary workaround try this one: