[RFC] Deprecated Table columns.render return cell props and use onCell
instead
#36886
Replies: 12 comments
-
Does it simpler if we add |
Beta Was this translation helpful? Give feedback.
-
or const columns = [{
dataIndex: 'name',
-- render: (val) => ({
-- props: { colSpan: 2 },
-- children: val,
-- });
++ span: (val, index) => ({
++ col: 2,
++ row: 0,
++ }),
}]; |
Beta Was this translation helpful? Give feedback.
-
Consider mix usage: span: (record, index) => ({
col: index === 0 ? 2 : 1,
row: 0,
}),
onCell: (record, index) => ({
className: index === 0 ? 'my-class-name' : null,
}), vs onCell: (record, index) => ({
className: index === 0 ? 'my-class-name' : null,
colSpan: index === 0 ? 2 : 1,
rowSpan: 0,
}), The line count of |
Beta Was this translation helpful? Give feedback.
-
New to Ant, need some help. How do I handle the
as
but it didn’t work. |
Beta Was this translation helpful? Give feedback.
-
I have same issue,Have you solved it? |
Beta Was this translation helpful? Give feedback.
-
Yeah, try this: onCell: (record) =>{ render: (_, record) => { |
Beta Was this translation helpful? Give feedback.
-
howerve, i need some JSX in onCell,how can i do it |
Beta Was this translation helpful? Give feedback.
-
How to get Seems like deprecating I am asking this because table performance is still horrible, because of the hover issue. |
Beta Was this translation helpful? Give feedback.
-
works like magic, thanks however I also thinks is it really necessary divide use onCell just because of props?? In my case, I have to different colSpan and JSX according to record type. But in a new way, I have to write the same code twice. (categorize record types)... |
Beta Was this translation helpful? Give feedback.
-
Exactly! The |
Beta Was this translation helpful? Give feedback.
-
if you are looking to use different styles for each column consider this
|
Beta Was this translation helpful? Give feedback.
-
How would it work for rowSelection? I'm already using antd 4 (latest) and renderCell logs a warning |
Beta Was this translation helpful? Give feedback.
-
📋 RFC
Summary
Use
onCell
instead ofrender
returncell.props
.Basic example
Motivation
As #32979 mentioned. Table column mix props & node in one
render
function which cost additional perf calculation. And this will also makes row hover calculation no way to optimize. Since we already haveonCell
function and this is same logic asrender.props
, it's reasonable to de-duplicate.Detailed
To make this RFC done:
rc-table
and suggest user move toonCell
. Also keep origin span logic do not modified.onCell
base which will speed up render perfDrawbacks
No break of current usage. But get warning.
Adoption strategy
When finished dev will replace all demo to new usage.
Beta Was this translation helpful? Give feedback.
All reactions