Closed c06e closed 6 years ago
The main reason is a bit of laziness but it's also so that you can add a lot of customizability to the items. When you use an object, it can allow you to create a pretty complicated item like:
{
label: 'This is the item label',
value: 'value',
leftIcon: <Checkbox id="some-id" checked={isChecked('some-id')} name="multi-select" onChange={this.handleMultiSelect} />,
secondaryText: 'Some additional context',
... any other props ...
}
and since the ListItem
is still using an old component
paradigm, I can't safely remove all keys that can't be provided to the ListItem
since this is also valid:
{
label: 'This is the item label',
value: 'value',
component: CustomItem,
customProp1: 'something',
customProp2: 'something else',
... other props ...
}
I guess I understand that. Do you have a suggestion to compress the warnings in the console or is there a different way I should be constructing my SelectField implementation? I think if I put a loop within the SelectField and return the items as children, I get an entirely different error, so not sure what's the best approach.
Sorry, took me awhile to respond. You can always try to use the deleteKeys prop to remove those additional keys that are not needed.
I have an array of objects that I have bound to the SelectField and have specified an ItemLabel and ItemValue. The problem is, on line 952 in the _reduceItems function of SelectField.js, it's spreading all of the remaining properties of the item to the ListItem component, resulting in the following error. Any reason to maintain the prop spread on the ListItem?