material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[Dropdown Menu] value propType is React.PropTypes.object

Open tehleach opened this issue 11 years ago • 4 comments

I think this shouldn't have a strict propType. If it must, it should be type number. In Select Fields, the example value property is an int.

In my case, I found this when I tried passing in a whole selected menuItem { payload: 1, text: "LAX" } as value to a SelectFields component. This allowed me to select a component but it wouldn't display. When I passed the selected item's payload as value, it worked properly but I received warning

Warning: Failed propType: Invalid prop `value` of type `number` supplied to `DropDownMenu`, expected `object`. Check the render method of `Filter`.

I think the fix would be to just remove the value property from Dropdown Menu's propTypes. I can make a PR if this is correct.

tehleach avatar Dec 02 '15 18:12 tehleach

I think the fix would be to just remove the value property from Dropdown Menu's propTypes

Sorry, but I plan to move the documentation of each property from the doc to the source code. And I also plan to enforce the eslint rule react/prop-types.

Can we instead use the oneOf option for the PropType validation?

oliviertassinari avatar Dec 02 '15 20:12 oliviertassinari

Sure! Fine by me. I just wanted to be sure that I wasn't using the SelectField component improperly.

So that I can be sure, the value property should be of whatever type the valueMember property is on the menuItem, correct?

Should I go ahead with the PR to use oneOf then?

tehleach avatar Dec 02 '15 21:12 tehleach

I just wanted to be sure that I wasn't using the SelectField component improperly

It seems that you are using it as in the documentation. It should be the right way to do.

Having a look at this line https://github.com/callemall/material-ui/blob/master/src/drop-down-menu.jsx#L207. I would say that we can set the PropType of value to any. Could you add it to the SelectField too?

oliviertassinari avatar Dec 02 '15 22:12 oliviertassinari

edit: never mind, i had an old cached version. everything is good.

markshust avatar Jan 02 '16 00:01 markshust