【发布时间】:2021-03-11 13:05:40
【问题描述】:
我正在使用react-hook-form的控制器组件来调用材质UI自动完成。
当我传递defaultValue 参数时,它会填充到字段中,但是当单击提交按钮时会显示验证错误消息:
shared_with_users must be a `array` type, but the final value was: `null` (cast from the value `{ "value": "571998", "label": "\"Satyendra Kumar\"" }`). If "null" is intended as an empty value be sure to mark the schema as `.nullable()`
这是我的代码: https://codesandbox.io/s/nervous-tree-9e2js?file=/src/App.js
选择最后一个选择框后会自动完成。我正在使用 yup 进行表单验证。
请提出修复建议。
提前谢谢你
【问题讨论】:
标签: autocomplete material-ui yup react-hook-form