react-table cannot have column with name `id` / `ID`
See original GitHub issueHello.
‘@patternfly/react-table’ cannot have column named with name: id
/ ID
:
index.js:27 Warning: Encountered two children with the same key, `[object Object]-row`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
in tbody (created by BodyWrapper)
in BodyWrapper (created by BaseBody)
in BaseBody (created by Context.Consumer)
in Body (created by ContextBody)
in ContextBody (created by Context.Consumer)
in TableBody (created by SimpleTable)
in table (created by Provider)
in Provider (created by Table)
in Table (created by Context.Consumer)
in ComponentWithOuia (created by Context.Consumer)
in Unknown (created by SimpleTable)
in SimpleTable
It turned out that column cannot be named with id
.
Reproducer: https://codesandbox.io/s/mystifying-diffie-e0b0t That is a clone of the first official example: https://codesandbox.io/s/1h9p2 from : https://www.patternfly.org/v4/documentation/react/components/table
There is only 1 line change:
From:
'Branches',
{ title: 'Pull requests' },
changed to:
"Branches",
{ title: "Id" },
And in console (press F12) you will see messages:
Encountered two children with the same key, `[object Object]-row`.
I spent 3 hours to understand the cause. Chance that a developer names column with name id
/ ID
/ Id
is very high.
Version: “@patternfly/react-table”: “^2.28.47”,
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Error: React-Table: Could not find a column with id
I'm trying to make my columns searchable, but I keep getting an error that says there are no columns with the id '-whatever...
Read more >Typescript type error on Quick start example? #2664 - GitHub
I just started using react table and I keep getting a type error when trying to use ... interface WhiteListEntry { id: string;...
Read more >React Table: A Complete Guide - Hygraph
This guide will teach us how to efficiently use the react-table library to create tables in our React application.
Read more >Columns | TanStack Table Docs
Display columns do not have a data model which means they cannot be sorted, filtered, etc, but they can be used to ......
Read more >React Table Tutorial - 3 - Basic Table - YouTube
Your browser can't play this video. Learn more. Switch camera.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Andrei-Stepanov I wonder who put the
This prop should not be set manually
as it’s not correct and should on other side describe the behavior, similiar to documentation on reactabular.EDIT: Same logic should be applied to
onRow
and override it only if consumer does not provide such function.@Andrei-Stepanov you can have columns with name ID, however you’ll also have to pass
rowKey
to TableBody component. This is limitation of reacttabular component used to build the table itself. If you want to deep dive into how reactabular and settingrowKey
works check out their documentation - https://reactabular.js.org/#/table/components Since table is using reactabular you can write a lot of ehancer functions as well, I am wondering why there is no reference to the package in docs as that would prevent such questions in future @redallen .