I am using AntD <Table />
component. When I am generating the columns I want to pass custom props to my cells that are not part of the data I am feeding the table. It could be things like theme, color palette, layout setting etc..
Each column is represented by an object and has a render
method. AntD iterates over the rows and the columns and passes the record
of that row to be rendered by the given cell
.
{
... // keys like `key`, `title`, `dataIndex` ...
render: (record) => {...}
}
Instead of passing my extra props to the component itself directly like this:
{
... // keys like `key`, `title`, `dataIndex` ...
render: (record) => <MyCell {...record} extraProp={extraProp} extraProp2={extraProp2} />
}
I got in the habit of writing something like this:
{
... // keys like `key`, `title`, `dataIndex` ...
render: MyCell(extraProp, extraProp2)
}
Where MyCell is defined as:
const MyCell = (extrProp, extraProp2) => props => {...}
Should I stick to using regular props? Or is it fine if I pass my extra props like this?
Will it incur bad performance? Will it bite me in the future, giving me bugs hard to trace?
Thanks
Aucun commentaire:
Enregistrer un commentaire