React table value-based styling
I may be confused but it seems to me that in the former
react-table
v7 version, we used to have more control on the way the rows would be rendered. In the attached screenshot (codesandbox https://codesandbox.io/s/ancient-frog-rsx361), I'd rather have the styling set at the <td/>
level, not its child (so that padding would look cleaner).
What's the right approach for this with v8 ?
Old version (<td/> would get its own cell-value-based styling getColumnProps
+ getCellProps
)
New v8 version (<td/> styling no longer affected by cell value)
Thanks
2 Replies
wise-white•3y ago
For me, I would set
columnDef.meta.td.className
and columnDef.meta.td.style
so that I can:
Also use declaration merging for better TypeScript experience:
https://tanstack.com/table/v8/docs/api/core/column-def#metaColumnDef | TanStack Table Docs
Column definitions are plain objects with the following options:
Options
absent-sapphireOP•3y ago
I've played with your solution, it seems flexible enough for my use case. The docs for TS declaration merging were useful.
Thanks @Z. Aru