Passing columns as props to a React component
What is the correct type for columns definitions when passing them as props? I am using
ColumnDef<unknown>[]
but I cannot pass column definitions I have defined in other component.
2 Replies
genetic-orangeOP•3y ago
It works when I add generic parameter
But I need to have any here, it does not work when I put unknown here
fair-rose•3y ago
I think you can achieve this by creating column defs separately as a component and then passing it to your "PlainTableComponent" .
Actually I think its better explained in the codebase for this table which is using ShadCN Ui with tanstack but I guess the same aproach can be applied here.
https://ui.shadcn.com/examples/tasks
Follow the component structure here. Hope this helps