This is very annoying.
You can't set the value by props, and intercept the new value selected to set it in the state...
Can you fix that, all the other form field have this "defaultValue" props.
SelectField seems to can switch between uncontroled and controled value without throwing an error.
My bad sorry.
@Kornflexx I am not sure I understand what you mean. I have the same problem, I need to use a SelectField as uncontrolled component, and SelectFields should support the defaultValue
attribute, according to React's docs, which it currently does not. Unless I am mistaken, could you re-open this issue ?
Google brought me here.. I also want to use an uncontrolled SelectField
.
Any chances?
Me too!
Can anyone please tell me how to use defaultValue on an uncontrolled SelectField?
@Zregnateews if you are using "next" version you can do the following:
<Select native defaultValue={30}}>
<option value="" />
<option value={10}>Ten</option>
<option value={20}>Twenty</option>
<option value={30}>Thirty</option>
</Select>
https://material-ui-next.com/demos/selects/
Hope it helps you!.
Ran into this issue myself i will just leave this here for the next dev who runs into this issue
ie :
<Select
displayEmpty
defaultValue="value"
renderValue={ () => dashboardState.month}
onChange={e => handleChange(e.target.value) } >
{ ...options }
</Select>
Most helpful comment
@Kornflexx I am not sure I understand what you mean. I have the same problem, I need to use a SelectField as uncontrolled component, and SelectFields should support the
defaultValue
attribute, according to React's docs, which it currently does not. Unless I am mistaken, could you re-open this issue ?