-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Support objects with <Select> #10845
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@oliviertassinari Sure: https://codesandbox.io/s/8x8r5plx32?module=%2Fsrc%2Fpages%2Findex.js @astridcst In my codesandbox example I didn't add 'material types' and it is still showing me these warnings, so I don't think this is the problem or I just didn't get it what you mean. |
@npeham Thanks a lot for the reproduction example! The {
id: 1,
name: "StepOne"
} While it's "working", it comes with two drawbacks:
Here is an updated version without the warning https://codesandbox.io/s/1yvymk2r67. Now, I think that we should something about this confusing warning message. I have seen it too personally, wtf: |
I have some issue, I think problem is when pass a array of object to value This data will show warning: [
{id: 1, value='One'},
{id: 2, value='Two'}
] |
I think that the best step going forward is to write a custom prop-type validator. The warning message isn't actionable right now: |
@oliviertassinari About updated version, its works with single selects, but still have problem with multiple selects in renderValue* Can't use this approach: renderValue: selected =>
{selected.map(value =>
<Chip key={value.id} label={value.name} />
)} |
+values = {…}
renderValue: selected =>
{selected.map(value =>
- <Chip key={value.id} label={value.name} />
+ <Chip key={values[value].id} label={values[value].name} />
)} |
In this case can't pass .id to MenuItem, need pass index, then when pass state to POST need use map to get all IDs:
Data to POST:
|
After some digging, I have realized that it's a broader issue with the |
@oliviertassinari Using the id as value for both MenuItem and Select works well. I understand now. Thank you very much! |
@oliviertassinari Thanks, I'll follow. |
@oliviertassinari Sorry for commenting on closed issue, but I think 'boolean' should be defined as a valid type for 'value'. I have a Select with true / false values and I got invalid prop type warning. |
@ali-jalaal I haven't looked into the boolean. Interesting concern. As long as it's working for both the native and non-native select component, I think that we should be officiality supporting it :). |
I am seeing this issue in the latest version. And, regarding your reply about using only
If the list of MenuItem elements contain an |
@don-p Do you have a minimal reproducible example? I've upgraded the reproduction above to use the latest version and it works fine. https://codesandbox.io/s/kon52opp4r |
If you care about the actual values in the input you should always manually cast them to strings. The DOM doesn't allow for non-string values on The type is wider in the This is in line with how For typescript users the current behavior is confusing though since |
Expected Behavior
Not showing warnings when passing an object as value to the Select component.
Current Behavior
It works but it is showing these warnings:
Warning: Failed prop type: Invalid prop 'value' supplied to 'Select'.
Warning: Failed prop type: Invalid prop 'value' supplied to 'Input'.
Warning: Failed prop type: Invalid prop 'value' supplied to 'SelectInput'.
Steps to Reproduce (for bugs)
Thats my component in which I use the Select component. As you can see
this.props.selectedWorkingStep
is an object which causes those warnings.PropTypes:
CodeSandbox example
https://codesandbox.io/s/8x8r5plx32?module=%2Fsrc%2Fpages%2Findex.js
Context
Its not that critical because it is working for me(maybe there are errors which I don't encountered yet). Maybe #10834 has the same problem but I don't know it is the same reason for the warning because my warnings show up not depending on if I select an item of the Select.
Your Environment
The text was updated successfully, but these errors were encountered: