-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown: items missing "key" prop, React warning displayed #1710
Comments
Note, adding a
This wasn't the case for 0.68.3. I see a reference to |
Looks to be an intended change. This issue is mentioned in the latest release documentation: So does this mean we need @karlludwigweise @davezuko |
From my understanding, @levithomason I am, however, curious about this line: Semantic-UI-React/src/lib/factories.js Line 87 in 754416e
value is being used correctly as the default? Maybe I missed something in the DropdownItem change?
|
I have a small problem, though: react throws the unique key prop error when |
This is the reason I did not want to make the change myself. The Dropdown is too big of a component to oversee for a first time change; for me at least. The component should ideally generate its own keys and use those. |
@karlludwigweise, no stress, we have a work around. Let's see what @levithomason says about the factory before we continue. |
Here is problem with a factory. It will generate key only when element passed to it as I will make PR that fixes this. |
This is actually not a bug, if you pass a string/number primitive then we'll assume that as they key. Otherwise, if you pass an options object or an element then you need to supply your own key just as is required by React itself.
Yep. Anytime you use an object or an element in an array you'll need to pass a key. If you use primitive shorthand (i.e. a string or number) then the shorthand factory will assume that value as the key. @davezuko Tangent: the hidden select arguably should go away entirely, it is an artifact from the old days. @jhartma |
@levithomason nice, thanks a lot for the quick fix |
@levithomason it seems that you don't understand the problem described there. In #1639 we broken automatic |
@layershifter thanks for pointing out my oversight. There are two points here:
I'll update the PR you submitted to fix number 2 above. This way, all keys in all components are fixed. |
Released in |
The problem still exists. This is the array I passed in as options: This is my Dropdown code:
And this is what is generated: As you can see in |
Note, React doesn't render If you create a minimal repo showing the issue, we can investigate further. |
Is there a way to specify a different object property as the key, such as the unique id that might be returned from the server? something like |
@rawberg both |
Keys in Dropdown options are still required and still work. If you do not pass a |
Steps
Dropdown
element with more than oneoption
specified.selection
needs to be specified also.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
The text was updated successfully, but these errors were encountered: