Semantic-UI-React: Dropdown: items missing "key" prop, React warning displayed

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

About this issue

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

Most upvoted comments

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.

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.

Released in semantic-ui-react@0.68.5.

@karlludwigweise, no stress, we have a work around.

Let’s see what @levithomason says about the factory before we continue.