T
TanStack2y ago
afraid-scarlet

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
eastern-cyan
eastern-cyan2y 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.
afraid-scarlet
afraid-scarletOP2y ago
@lakeway Not sure I understand how to fix it in my case. Could you please help?

Did you find this page helpful?