Skip to content

Creating Table component using shorthand component causes "keys" warning #1205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
georges-hatem opened this issue Jan 23, 2017 · 3 comments
Closed
Labels

Comments

@georges-hatem
Copy link

React / ReactDOM version: 15.4.2
Semantic UI React version: 0.64.3

Warnings:

  • Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of Table.
  • Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of TableRow.

The Codepen below does specify a key for each dataRow, but not for headerRow values.
Could that be the issue? If so, under what key should the header values be placed? (i tried turning headerRow into a dictionary, but the rendering would not know how to pick up the header vals)

http://codepen.io/khorkhe/pen/ggWEmm

@levithomason
Copy link
Member

The tableData has keys, however, the table cells do not:

cells: [
  name || 'No name specified',
  status ? {
    icon: 'attention',
    content: status
  } :
  'Unknown',
  notes ? {
    icon: 'attention',
    content: notes,
    warning: true
  } :
  'None',
],

The TableCell shorthand objects must have a key as well. When I add a key to those, the warnings go away.

@georges-hatem
Copy link
Author

I see. I had tried this:

const renderBodyRow = ({ name, status, notes, key }) => ({
  cells: [ name, status, notes, key ],
})

when it really should have been this:

const renderBodyRow = ({ name, status, notes, key }) => ({
  cells: [ name, status, notes ],
  key
})

Sorry for the trouble

@levithomason
Copy link
Member

No worries, thanks for using SUIR and reporting issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants