T
TanStack17mo ago
rival-black

Types for table

import { Table as TTable } from '@tanstack/react-table';

interface DataTableProps<TData, TValue> {
columns: ExtendedColumnDef<TData, TValue>[];
data: TData[];
isLoading?: boolean;
}

export const DataTable = forwardRef<TTable<any>, DataTableProps<any, unknown>>(
import { Table as TTable } from '@tanstack/react-table';

interface DataTableProps<TData, TValue> {
columns: ExtendedColumnDef<TData, TValue>[];
data: TData[];
isLoading?: boolean;
}

export const DataTable = forwardRef<TTable<any>, DataTableProps<any, unknown>>(
What can I use instead of any? I tried TData but it says TS2304: Cannot find name TData. I don't want to pass the data type because it's a reusable table.
2 Replies
solid-orange
solid-orange17mo ago
Total TypeScript
How To Use forwardRef With Generic Components
Learn about the limitations of React's forwardRef TypeScript and discover a solution to enable inference on generic components.
rival-black
rival-blackOP17mo ago
@lakeway Not sure I understand how to fix it in my case. Could you please help?

Did you find this page helpful?