Dropdown: items missing "key" prop, React warning displayed
See original GitHub issueSteps
- Update from version 0.68.3 to 0.68.4.
- Introduce a
Dropdown
element with more than oneoption
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:
- Created 6 years ago
- Reactions:6
- Comments:19 (13 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
Here is problem with a factory.
It will generate key only when element passed to it as
number
orstring
. When element is passed as object, factory expects that user will definekey
himself.I will make PR that fixes this.
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:
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.