[在使用KendoReact库的react-hook-form组件时遇到麻烦:
<Controller
as={Input}
name="firstName"
control={control}
defaultValue="type something here"
/>
react-hook-form sample正在使用MaterialUI组件显示第三方库集成,并且似乎工作正常。使用Kendo输入组件时,在输入控件中键入任何内容都会导致控件显示[object Object]
而不是键入的值。这是因为要在控件上设置的值是event
对象,而不是实际值。
我找不到解决此问题的方法,希望其他人确实找到了解决方法。
在Input周围创建一个简单的包装以从onChange
中获取值将起作用:
const InputWrapper = props => {
return <Input {...props} onChange={e => {
props.onChange(e.target.value)
}} />
}
...
<Controller
as={InputWrapper}
name="firstName"
control={control}
defaultValue="type something here"
/>