📜  Material-UI:一个组件在初始化后正在改变一个不受控制的 Select 的默认值状态.要抑制此警告,请选择使用受控选择. - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:55.345000             🧑  作者: Mango

代码示例1
/** Uncontrolled here means you may be setting the value
of the Select component to undefined, this is because 
value={props.selectedValue} here. In this the props or 
selectedValue may come null so it turns out to be a
uncontrolled component in that.
To solve the warning you can add condition to check null 
and set default value.
*/

value={props.selectedValue ? props.selectedValue : " "}