question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set `key` for <th /> in <Table /> ?

See original GitHub issue

What problem does this feature solve?

Normally, Antd sets auto-Increment number as key for <th />. In most of the cases, it’s fine.

But, when the columns changes frequently, this will cause some unnecessary unmount and mount. Especially when I use a React component as some columns’ title.

What does the proposed API look like?

const columns = [];

// when set columns, it can use the key for `<th />`, not only `<td />`
columns.push({
  title: <SomeComponent />,
  dataIndex: 'name',
  key: 'name'
});

return <Table columns={columns} />;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
yesmeckcommented, Jan 23, 2018

Try rc-table@6.1.4, will use column.key || column.dataIndex as key

1reaction
afc163commented, Jan 23, 2018

Can we use column.key for th defaultly?

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML th tag - W3Schools
The <th> tag defines a header cell in an HTML table. An HTML table has two kinds of cells: ... The text in...
Read more >
Create key on a data.table — setkey • data.table - GitLab
setkey sorts a data.table and marks it as sorted with an attribute "sorted" . The sorted columns are the key. The key can...
Read more >
<th>: The Table Header element - HTML - MDN Web Docs
The <th> HTML element defines a cell as header of a group of table cells. The exact nature of this group is defined...
Read more >
Add a primary key to a table in Access - Microsoft Support
In the Navigation Pane, right click a table, and select Design View. Select the field or fields you want to use as the...
Read more >
What is the purpose of setting a key in data.table?
setkey () sorts a data.table and marks it as sorted. The sorted columns are the key. The key can be any columns in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found