0

I am using primereact dropdown component https://primefaces.org/primereact/showcase/#/dropdown

But getting this warning:-

react_devtools_backend.js:2450 Warning: Encountered two children with the same key. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
in ul (created by DropdownPanel)
in div (created by DropdownPanel)

this.cities = [
            { name: 'Apple', code: '1' },
            { name: 'Rome', code: '2' },
            { name: 'Rome', code: '3' },
            { name: 'Paris', code: '4' },
            { name: 'Paris', code: '5' }
        ];

<Dropdown 
    value={this.state.selectedCity1} 
    options={this.cities} 
    onChange={this.onCityChange} 
    optionLabel="name" 
    placeholder="Select a City" />

How to fix this in primereact dropdown.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Mahi
  • 3,748
  • 4
  • 35
  • 70

1 Answers1

0

Maybe you should to add optionValue="code"?

<Dropdown
  value={this.state.selectedCity1}
  options={this.cities}
  onChange={this.onCityChange}
  optionLabel="name"
  optionValue="code"
  placeholder="Select a City"
/>
Alexandr
  • 522
  • 2
  • 10