Loading problem…
Build a Data Table component in React that displays tabular data with column sorting functionality.
interface Column<T> {
key: keyof T;
label: string;
sortable?: boolean;
}
interface DataTableProps<T> {
data: T[];
columns: Column<T>[];
}const columns = [
{ key: 'name', label: 'Name', sortable: true },
{ key: 'age', label: 'Age', sortable: true },
{ key: 'email', label: 'Email', sortable: true },
];
const data = [
{ name: 'John Doe', age: 28, email: 'john@example.com' },
{ name: 'Jane Smith', age: 32, email: 'jane@example.com' },
];
<DataTable data={data} columns={columns} />