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.

Dropdown: items missing "key" prop, React warning displayed

See original GitHub issue

Steps

  • Update from version 0.68.3 to 0.68.4.
  • Introduce a Dropdown element with more than one option specified. selection needs to be specified also.
  • Run.

Expected Result

No warning from React.

Actual Result

React error: Warning: Each child in an array or iterator should have a unique "key" props. Check the render method of 'Dropdown'.

Version

0.68.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:19 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
layershiftercommented, May 31, 2017

Here is problem with a factory.

It will generate key only when element passed to it as number or string. When element is passed as object, factory expects that user will define key himself.

I will make PR that fixes this.

1reaction
SidecarMastercommented, Aug 30, 2017

The problem still exists. This is the array I passed in as options: [{key: "react", value: "react", text: "react"}, {key: "redux", value: "redux", text: "redux"}, {key: "udacity", value: "udacity", text: "udacity"}

This is my Dropdown code:

        <Dropdown
          selection
          label={field.label}
          options={options}
          placeholder='Select Category'
          error={errorAttr}
          >
        </Dropdown>

And this is what is generated: <div label="Select Category " role="listbox" aria-expanded="false" class="ui selection dropdown" tabindex="0"><div class="text" role="alert" aria-live="polite">react</div>...</div>

As you can see in <div class="text" role="alert" aria-live="polite">react</div> It still doesn’t have a key even if the object I passed in has a key property.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dropdown: items missing "key" prop, React warning displayed
Your key generated there isn't unique while React requires unique keys. Similar answer was there.
Read more >
React Dropdown: Still getting 'unique key prop' warning after ...
Tried using both 70 and '70' for the id property. Warning still appears. Using the array index as the key eliminates the warning,...
Read more >
How to Fix 'Each child should have a unique key prop' - Webtips
The "Each child in a list should have a unique "key" prop." warning happens in React when you create a list of elements...
Read more >
Warning: Each Child in a List Should Have a Unique 'key' Prop
When creating a list in the UI from an array with JSX, you should add a key prop to each child and to...
Read more >
Accessibility - React
function Glossary(props) { return ( <dl> {props.items.map(item => ( // Fragments should also have a `key` prop when mapping collections <Fragment ...
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