我收到此警告:Warning: The `value` prop supplied to <select> must be a scalar value if `multiple` is false. Check the render method of `Control`.
我正在使用React Redux表单https://davidkpiano.github.io/react-redux-form/docs/api/Control.html#prop-defaultValue。
数据作为对象数组输入,以显示在select options元素内部。我不想将控件变成多个,因为我们只希望用户选择一个值。
我将如何解决此警告?
最佳答案
如果您在自己的状态下使用数组,则在不进行多次搜索的情况下将得到该错误
如果是简单搜索,请使用单引号''
在中useState('')
const [categoria, setCategoria] = useState('')
<select
onChange={e => setCategoria(e.target.value)}
value={categoria}
>
</select>
关于javascript - react : The `value` prop supplied to <select> must be a scalar value if `multiple` is false,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47721427/