Semantic-UI-React: Dropdown: items missing "key" prop, React warning displayed
Steps
- Update from version 0.68.3 to 0.68.4.
- Introduce a
Dropdownelement with more than oneoptionspecified.selectionneeds 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
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 19 (13 by maintainers)
Here is problem with a factory.
It will generate key only when element passed to it as
numberorstring. When element is passed as object, factory expects that user will definekeyhimself.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.Released in
semantic-ui-react@0.68.5.@jhartma fixed in https://github.com/Semantic-Org/Semantic-UI-React/pull/1727, it will go out on the next release.
@karlludwigweise, no stress, we have a work around.
Let’s see what @levithomason says about the factory before we continue.