Making a rusable table column generic
Hello guys, I am trying to make a reusable table, but having a hard time making the columns props it takes a generic i've tried something like this ` and no luck have also tried other alternatives, but keep getting errors, any ideas, how this should actually look?
3 Replies
equal-aquaOP•2y ago
doing something like this works i guess
columns: ColumnDef<TData, any>[];
not sure if this is the correct way to type itwise-white•2y ago
I'd probably check out this example from ui shadcn
https://ui.shadcn.com/examples/tasks
the full code is available here.
https://github.com/shadcn-ui/ui/tree/main/apps/www/app/examples/tasks
personally I'd have to say I don't like how they mixed the dynamic rendering with the component using useReactTable() here (https://github.com/shadcn-ui/ui/blob/main/apps/www/app/examples/tasks/components/data-table.tsx)
and you can go a step further for reusability to have something like this instead
equal-aquaOP•2y ago
You can see that the actual table for the prop though, is actually similar to what I’ve tried and didn’t work out