Semantic-ui-react: Dropdown with object as value throws warning

Created on 27 Feb 2019  路  3Comments  路  Source: Semantic-Org/Semantic-UI-React

The Dropdown options property accepts a single value or an array of values.
In most cases however, the 'dataprovider' of a dropdown would be an array of objects retrieved from a service.
Referencing a selected object in the dropdown is important. So I set the value property in the options to the object itself.
To see an example, here's a codesandbox.

As you can see, this works perfectly but two warnings will be thrown in the console:

Warning: Failed prop type: Invalid prop `options[0].value` supplied to `Dropdown`. 
in Dropdown`
Warning: Failed prop type: Invalid prop `value` supplied to `DropdownItem`.
in DropdownItem`

If passing object as value to the options property works without a problem, then the warning should be omitted.

wontfix

Most helpful comment

You should pass value as string it's a known limitation and there will be no changes in a short-term.

All 3 comments

You should pass value as string it's a known limitation and there will be no changes in a short-term.

Has there been a discussion in the past on this topic? It's a very handy feature and it actually _works_

You can search in our issues. actually it's works partially. There are many places in the Dropdown component where it uses === (deep equal) check on values and will silently break the object compassion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eXtreme picture eXtreme  路  3Comments

keeslinp picture keeslinp  路  3Comments

KevinGorjan picture KevinGorjan  路  3Comments

Ctesias picture Ctesias  路  3Comments

dilizarov picture dilizarov  路  3Comments